我想制作一个登录表单,但我不知道如何使用登录按钮中的 DLookup 获取或确认我在用户名和密码文本框中输入的内容是否在我的表格中。
这是我当前的代码:
Dim u As Variant
Dim p As Variant
Dim inu As String
Dim inp As String
u = DLookup("cusername", "tbl_users", "inuser.Value")
p = DLookup("cpassword", "tbl_users", "inpass.Value")
inu = inuser.Value
inp = inpass.Value
If inu = u And inp = p Then
DoCmd.OpenForm "frm_userlog"
MsgBox "Welcome " & tuser & "!"
ElseIf IsNull(Me.inuser.Value) And inpass.Value = 1 Then
MsgBox "You must input a username"
ElseIf IsNull(Me.inpass.Value) And inuser.Value = 1 Then
MsgBox "you must input a password"
ElseIf IsNull(Me.inuser.Value) And IsNull(Me.inpass.Value) Then
MsgBox "you must input a username and password"
Else
MsgBox "The username or password you entered is invalid"
End If
End Sub