Results 1 to 6 of 6
  1. #1
    papa yaw is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    4

    Method or data member not found


    Code:
    Private Sub cmdLogin_Click()
       Static count As Integer
       'Check if data is entered in the Employee Id box'
       If IsNull(Me.txtEmployeeId) Or Me.txtEmployeeId = "" Then
          MsgBox "You must enter an Employee Id.", vbOKOnly, "Required Data"
          Me.txtEmployeeId.SetFocus
          Exit Sub
       End If
       'Check to see if data is entered into the password box'
       If IsNull(Me.txtPassword) Or Me.txtPassword Then
          MsgBox "You must enter a password.", vbOKOnly, "Required Data"
          Me.txtPassword.SetFocus
          Exit Sub
       End If
       EmployeeId = Nz(DLookup("strEmployeeId", "tblEmployeeLogin", "StrEmployeeId='" & Me.txtEmployeeId & "'"), "")
       Password = Nz(DLookup("strPassword", "tblEmployeeLogin", "strPassword='" & Me.txtPassword & "'"), "")
       If Me.EmployeeId = EmployeeId And Me.txtPassword = Password Then
          MsgBox "Access Granted", vbInformation, "Logging into Database"
          DoCmd.Close
          DoCmd.OpenForm "Menu"
       Else
          MsgBox "Access Denied"
          count = count + 1
          If count = 3 Then
             MsgBox "You have failed to login on three tries", vbCritical, "Exiting...."
             DoCmd.CloseDatabase
          End If
       End If
    End SubPrivate Sub Login_Click()
       Static count As Integer
       'Check if data is entered in the Employee Id box'
       If IsNull(Me.txtEmployeeId) Or Me.txtEmployeeId = "" Then
          MsgBox "You must enter an Employee Id.", vbOKOnly, "Required Data"
          Me.txtEmployeeId.SetFocus
          Exit Sub
       End If
       'Check to see if data is entered into the password box'
       If IsNull(Me.txtPassword) Or Me.txtPassword Then
          MsgBox "You must enter a password.", vbOKOnly, "Required Data"
          Me.txtPassword.SetFocus
          Exit Sub
       End If
       EmployeeId = Nz(DLookup("strEmployeeId", "tblEmployeeLogin", "StrEmployeeId='" & Me.txtEmployeeId & "'"), "")
       Password = Nz(DLookup("strPassword", "tblEmployeeLogin", "strPassword='" & Me.txtPassword & "'"), "")
       If Me.EmployeeId = EmployeeId And Me.txtPassword = Password Then
          MsgBox "Access Granted", vbInformation, "Logging into Database"
          DoCmd.Close
          DoCmd.OpenForm "Menu"
       Else
          MsgBox "Access Denied"
          count = count + 1
          If count = 3 Then
             MsgBox "You have failed to login on three tries", vbCritical, "Exiting...."
             DoCmd.CloseDatabase
          End If
       End If
    End Sub
    Last edited by RuralGuy; 12-16-2012 at 03:41 PM. Reason: Added indenting and code tags

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Which line is giving you the error?

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    And your question/problem is????

    However, looking at your code and your subject line. I can tell a few things.

    * You do not have "Option Explicit" at the top of your code page. You should turn on this option. It requires you to declare variables.
    You should have:
    Code:
       Dim EmployeeId As String
       Dim Password As String

    * You are probably getting an error at this line (in both procedures):
    Code:
       If Me.EmployeeId = EmployeeId And Me.txtPassword = Password Then
    I would guess you do not have a control named "EmployeeId".
    Try using:
    Code:
       If Me.txtEmployeeId = EmployeeId And Me.txtPassword = Password Then
    "Data Member not found" means (to me) there is not a member in the controls collection named "EmployeeId"

  4. #4
    papa yaw is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    4
    No line is giving me an error, however when i click on the button in its form view i get a method or data member not found error.

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Can you do a Debug>Compile from the code window without error?

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    The top two lines of your module should be:

    Code:
    Option Compare Database
    Option Explicit
    Did you add "Option Explicit" (without quotes)

    Did you change "Me.EmployeeId" to "Me.txtEmployeeId"??

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Compiler error: Method or member not found
    By JosmithTwo in forum Programming
    Replies: 3
    Last Post: 11-26-2012, 07:10 AM
  2. Replies: 7
    Last Post: 06-08-2012, 09:55 PM
  3. Compile Error: Method or data member not found
    By subtilty in forum Programming
    Replies: 5
    Last Post: 02-09-2012, 07:56 AM
  4. Replies: 21
    Last Post: 12-25-2011, 08:17 AM
  5. trnsferspreadsheet method - no data
    By Lurmis in forum Programming
    Replies: 5
    Last Post: 09-24-2009, 08:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums