set password ให้สามารถ edit และไม่สารถ edit ได้ไหม
กระทู้เก่าบอร์ด อ.Yeadram

 1,631   5
URL.หัวข้อ / URL
set password ให้สามารถ edit และไม่สารถ edit ได้ไหม

สร้าง พาสเวิด ขึ้นมา มี user กับ admin

แล้วทีนี้ต้องการให้ Admin สามารถ Edit ข้อมูลได้แค่ คนเดียว
User ดูข้อมูลได้อย่างเดียว
ต้องทำยังไงคะ

5 Reply in this Topic. Dispaly 1 pages and you are on page number 1

1 @R20032
ไม่รู้ผมเข้าใจถูกเป่านะครับ พอดีไม่ค่อยเก่ง แต่เคยทำแบบ แยกสองฟอร์มอะครับ
ก็อบมาเหมือนกันแต่อีกฟอร์ม ตั้งค่าแต่ละช่องให้ล็อคไว้ครับ จะแก้ไขไม่ได้
2 @R20033
if user ="ABCD" then
me.allowedit =Flase
end if

อะไรประมาณนี้ ประยุกเอาครับ หลักๆ ไปเก็บค่า มาว่า เป็น Admin หรือไม่ ก็ได้
เมื่อ Form Load คุณค่อยกำหนดว่าจะให้ From แก้ไขได้ไม่
3 @R20043
ลองดูที่นี่ครับ
http://youtu.be/VLiPKDuRxcQ
4 @R20462
คุณต้องเขียนโค๊ดมาครับ แล้วมาดูกันว่าติดขัดตรงไหนครับเพราะแต่ละฟอร์มที่สร้างใช้ชื่อที่ต่างกัน
5 @R20463
ตัวอย่างครับ ที่ผมใช้อยู่ เมื่อเปิด
Option Compare Database

Private Sub Form_Close()
    Open_OK = False
End Sub

Private Sub Form_Open(Cancel As Integer)
    If Open_OK = False Then
        Cancel = Not Open_OK
    End If
    
End Sub

เมื่อปิด
Option Compare Database

Private Sub Form_Close()
    Open_OK = False
End Sub

Private Sub Form_Open(Cancel As Integer)
    If Open_OK = False Then
        Cancel = Not Open_OK
    End If
    
End Sub

โค๊ดสำหรับ log in
Private Sub bt_login_Click()
    Dim iLevel As String
    iLevel = Nz(DLookup("Level", "tb_Pass", "UserName = '" & Me.txtName & "' AND Password = '" & Me.txtPass & "'"))
    If iLevel & "" = "" Then
        MsgBox "wrong password"
    Else
        'MsgBox "your level is " & " " & iLevel
        Open_OK = True
        If iLevel = "admin" Then
            DoCmd.OpenForm "Main", , , , acFormEdit ' able to edit add manage
        ElseIf iLevel = "user" Then ' add only
            DoCmd.OpenForm "Main"
            Forms!main.AllowDeletions = False ' disable deletion
            Forms!main.AllowEdits = False ' disable edition
        ElseIf iLevel = "guest" Then ' see only
            DoCmd.OpenForm "Main", , , , acFormReadOnly
        End If
End If
End Sub

ตามวีดีโอเป๊ะ
@ ประกาศใช้งานเว็บบอร์ดใหม่ => บอร์ดเรียนรู้ Access สำหรับคนไทย
แล้วจะใส่ลิ้งอ้างอิงมาที่โพสต์เก่านี้หรือไม่ก็ตามสะดวกครับ
Time: 0.3075s