สอบถาม การกำหนดสิทธิ์ให้สามารถ Add และ Edit Form
กระทู้เก่าบอร์ด อ.Yeadram

 1,608   1
URL.หัวข้อ / URL
สอบถาม การกำหนดสิทธิ์ให้สามารถ Add และ Edit Form

ตอนนี้ระบบสามารถ log in ได้แล้วค่ะ แต่ยังไม่สามารถทำการกำหนดสิทธิ์ได้
Table login: มีฟิลด์ดังนี้ Login ID,Username,Password,Role
เช่น Login ID = 1,Username = Admin,Password = 1234,Role = Admin

-ต้องการให้Admin สามารถAdd และ Edit ได้ทุก Form
-ต้องการให้ User สามารถ Add และEdit ได้เฉพาะ Form "Transation"
-ต้องการให้ User ไม่สามารถแก้ไขข้อมูลของผู้อื่นที่ได้กรอกไปแล้ว
แต่ Editได้เฉพาะRecord ที่ตนเองเคยกรอก
อันนี้คือตัวอย่างCode Login ปัจจุบันที่ใช้ได้แล้วนะคะ
Private Sub cmdLogin_Click()
    Static intPswdCount As Integer
    Dim strThisUserPassword As String
    If IsNull(Me.txtUserID) Then
        MsgBox "You must enter Username", vbCritical, gstrAppTitle
        Me.txtUserID.SetFocus
    ElseIf IsNull(DLookup("[Password]", "[login]", "[Username] = [txtUserID]")) Then
        MsgBox "Username You entered is incorrect.", vbCritical, gstrAppTitle
        Me.txtUserID = ""
        Me.txtPassword = ""
        Me.txtUserID.SetFocus
    Else
        strThisUserPassword = DLookup("[Password]", "[login]", "[Username] = [txtUserID]")
       

    If Me.txtPassword = strThisUserPassword Or strThisUserPassword = "" Then
        gstrThisUser = DLookup("[UserName]", "[login]", "[Username] = [txtUserID]")
        gstrThisUserRole = DLookup("[Role]", "[login]", "[Username] = [txtUserID]")
        DoCmd.Close acForm, Me.Name
        MsgBox "Hello " & gstrThisUser & vbNewLine & "(" & gstrThisUserRole & ")", _
        vbInformation, gstrAppTitle
        DoCmd.OpenForm "Transaction", acNormal
        Else
            intPswdCount = intPswdCount + 1
            MsgBox "Password you entered is incorrect.", vbCritical, gstrAppTitle
            If intPswdCount < 3 Then
               Me.txtPassword = ""
               Me.txtPassword.SetFocus
            Else
               DoCmd.Close acForm, Me.Name, acSaveNo
            End If
        End If
    End If
End Sub
คือไม่ทราบว่าต้องใช้ code อะไรบ้างในการทำให้ได้ตาม Requirement ข้างต้น
รบกวนผู้รู้ช่วยตอบหน่อยนะคะ

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

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