vba Microsoft Visual Basic 编译错误方法或未找到数据成员

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27966121/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 05:51:00  来源:igfitidea点击:

Microsoft Visual Basic Compile Error Method or Data Member Not Found

vbams-accessms-access-2010

提问by mickeymouse

I have been working on a login system for my access database, the login system works fine but when i try to create a ACCDE it won't let me so based on the error I checked the code and vba gave me this error (Compile error: method or data member not found) when I compiled it, and help is appreciated. The code is below. Access says that this line is the error: (The Section With Stars Is The Found Error)[.txtLoginID]

我一直在为我的访问数据库开发登录系统,登录系统工作正常,但是当我尝试创建 ACCDE 时,它不会让我根据错误检查代码,vba 给了我这个错误(编译错误: 方法或数据成员未找到)当我编译它时,感谢帮助。代码如下。Access 说这一行是错误:(The Section With Stars Is The Found Error)[.txtLoginID]

If IsNull(Me.txtLoginID) Then

If IsNull(Me.txtLoginID) Then

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

回答by Mastercafe

Sure that the problem isn't on your main code.
When you try to compile any access application and create MDE/ACCDE application, you must verify your library and references.

Check on your VBA panel: TOOLS >> REFERENCES
And verify that you have all and haven't any line with: [ERROR] or [NOT FOUND]

Other possibility is that you are using DAO and ADO code and haven't referenced the library preferred. A Sample:
With ERROR: dim db as database
Correct: dim db as dao.database

Simply if you have some library problem or bad reference, the compilation process can't be completed and return an error over any part of code.

确保问题不在您的主代码上。
当您尝试编译任何访问应用程序并创建 MDE/ACCDE 应用程序时,您必须验证您的库和引用。

检查您的 VBA 面板:TOOLS >> REFERENCES
并确认您拥有所有且没有任何行:[ERROR] 或 [NOT FOUND]

其他可能是您正在使用 DAO 和 ADO 代码并且没有引用该库首选。示例:
错误:dim db as database
正确:dim db as dao.database

只要您有一些库问题或错误的引用,编译过程将无法完成并在代码的任何部分返回错误。