【发布时间】:2014-06-02 00:01:43
【问题描述】:
这是我的第一篇文章,我正在尝试从我的数据库创建一个 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
【问题讨论】:
-
错误发生在哪一行?
-
将
Option Explicit添加到代码顶部并编译它(调试 --> 编译)。 -
此部分已突出显示。 .txtLoginID & enderland 我试过你说的 & 用 Explicit 替换比较数据库,但它不起作用