Username.SetFocus
If Username = "user" And Password = "pass" Then
MsgBox "ยินดีต้อนรับสู่ระบบบันทึกข้อมูล"
DoCmd.Close
DoCmd.OpenForm "main"
Exit Sub
Else
MsgBox "กรุณาใส่ ชื่อและรหัส ให้ถูกต้อง"
End If
Static intLogonAttempts As Integer
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts >= 3 Then
MsgBox "คุณพยายามเข้าระบบเกินสามครั้ง กรุณาติดต่อผู้ดูแลระบบ", vbCritical, "ปิดโปรแกรม"
Application.Quit
End If
If DCount("Tuser", "Tlogin", "Tuser = '" & Username & "' and Tpass = '" & Password & "' ") > 0 Then
Private Sub Login_Click()
Username.SetFocus
If DCount("Tuser", "Tlogin", "Tuser = '" & Username & "' and Tpass = '" & Password & "' ") > 0 Then
MsgBox "ยินดีต้อนรับสู่ระบบบันทึกข้อมูล"
DoCmd.Close
DoCmd.OpenForm "main"
Exit Sub
Else
MsgBox "กรุณาใส่ ชื่อและรหัส ให้ถูกต้อง"
End If
Static intLogonAttempts As Integer
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts >= 3 Then
MsgBox "คุณพยายามเข้าระบบเกินสามครั้ง กรุณาติดต่อผู้ดูแลระบบ", vbCritical, "ปิดโปรแกรม"
Application.Quit
End If
LastUserName = Username
End Sub
Username.SetFocus
Dim StartForm As Variant
StartForm = DLookup("TStartForm", "Tlogin", "Tuser = '" & Username & "' and Tpass = '" & Password & "' ")
If Not IsNull(DLookup) Then
MsgBox "ยินดีต้อนรับสู่ระบบบันทึกข้อมูล"
DoCmd.Close
DoCmd.OpenForm StartForm
Exit Sub
Else
MsgBox "กรุณาใส่ ชื่อและรหัส ให้ถูกต้อง"
End If
Static intLogonAttempts As Integer
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts >= 3 Then
MsgBox "คุณพยายามเข้าระบบเกินสามครั้ง กรุณาติดต่อผู้ดูแลระบบ", vbCritical, "ปิดโปรแกรม"
Application.Quit
End If
LastUserName = Username
ข้อผิดพลาดนี้เกิดขึ้นเมื่อไม่สามารถเรียกใช้เหตุการณ์ได้เนื่องจากไม่สามารถประเมินตำแหน่งที่ตั้งของตรรกะสำหรับเหตุการณ์ได้ ตัวอย่างเช่น ถ้าคุณสมบัติ OnOpen ของฟอร์มถูกตั้งค่าเป็น =[Field] ข้อผิดพลาดนี้จะเกิดขึ้นเนื่องจากคาดว่าแมโครหรือชื่อเหตุการณ์จะทำงานเมื่อเหตุการณ์นั้นเกิดขึ้น
Username.SetFocus
If DCount("ชื่อฟิลด์ผู้ใช้","ชื่อเทเบิลผู้ใช้","ชื่อฟิลด์ผู้ใช้ = '" & UserName & "' and ชื่อฟิลด์รหัสผ่าน = '" & Password & "' ") > 0 then
MsgBox "ยินดีต้อนรับสู่ระบบบันทึกข้อมูล"
DoCmd.Close
DoCmd.OpenForm "main"
Exit Sub
Else
MsgBox "กรุณาใส่ ชื่อและรหัส ให้ถูกต้อง"
End If
Static intLogonAttempts As Integer
Static LastUserName As String
If UserName = LastUserName then
intLogonAttempts = intLogonAttempts + 1
Else
intLogonAttempts = 1
End If
If intLogonAttempts >= 3 Then
MsgBox "คุณพยายามเข้าระบบเกินสามครั้ง กรุณาติดต่อผู้ดูแลระบบ", vbCritical, "ปิดโปรแกรม"
Application.Quit
End If