这是我的第一篇文章,我正在尝试从我的数据库创建一个accde数据库文件,我不断收到错误消息&我决定仔细查看我的VBA代码,运行调试并且我一直收到错误编译错误方法或找不到数据成员。我的代码在下面任何帮助非常感谢!在此先感谢
Option Compare Database
Private Sub Command1_Click()
Dim UserLevel As Integer
Dim TempPass As String
Dim ID As Integer
If IsNull(Me.txtLoginID) Then
MsgBox "Please Enter LoginID", vbInformation, "LoginID Required"
Me.txtLoginID.SetFocus
ElseIf IsNull(Me.txtpassword) Then
MsgBox "Please Enter Password", vbInformation, "Password Required"
Me.txtpassword.SetFocus
Else
'process the job
If (IsNull(DLookup("UserLogin", "tblUser", "UserLogin='" & Me.txtLoginID.Value & "'"))) Or _
(IsNull(DLookup("Password", "tblUser", "Password='" & Me.txtpassword.Value & "'"))) Then
MsgBox "Incorrect LoginID or Password"
Else
UserLevel = DLookup("UserSecurity", "tblUser", "UserLogin = '" & Me.txtLoginID.Value & "'")
TempPass = DLookup("password", "tblUser", "password = '" & Me.txtpassword.Value & "'")
ID = DLookup("UserID", "tblUser", "UserLogin = '" & Me.txtLoginID.Value & "'")
DoCmd.Close
If (TempPass = "password") Then
MsgBox "Please Change Your Password", vbInformation, "New Password Required"
DoCmd.OpenForm "tblUser", , , "[UserID] = " & ID
Else
If UserLevel = 1 Then
'MsgBox "Login Sucussfull"
DoCmd.OpenForm "Admin Navigation Form"
Else
If UserLevel = 2 Then
'MsgBox "Login Sucussfull"
DoCmd.OpenForm "Area Director Navigation Form"
If UserLevel = 2 Then
DoCmd.LockNavigationPane -1
Else
DoCmd.OpenForm "Area Director Navigation Form"
End If
End If
End If
End If
End If
End If
End Sub
答案 0 :(得分:0)
它可能是txtLoginID的数据类型。它是文本还是数字字段?如果是number,请删除DLookUps中的单引号,如下所示:
一个:
DLookup("UserSecurity", "tblUser", "UserLogin = '" & Me.txtLoginID.Value & "'")
变化:
DLookup("UserSecurity", "tblUser", "UserLogin = " & Me.txtLoginID.Value)
查看代码的其他附注: