Method or data member not found error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mose Mbugua
    New Member
    • Aug 2014
    • 17

    Method or data member not found error

    I'm trying to make a username and password form in access 2007. After keeing in the below code, an error message showing "Method or data member not found" what might be the cause?

    Code:
    Private Sub Command5_Click()
    Username.SetFocus
    If Username = "staff1" And Password = "staff1" Then
    MsgBox "Access granted", vbInformation, "school system2"
    MsgBox "Welcome", vbInformation, "school system"
    DoCmd.Close
    DoCmd.OpenForm "School_system"
    Else
    MsgBox "Access denied Please enter your username and password"
    else if
    End Sub
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32636

    #2
    Line #10 says else if instead of End If.

    Please read Before Posting (VBA or SQL) Code. This gives tips that will help you so much you won't even have to ask many of the questions you might otherwise need to ask.

    Comment

    • mose Mbugua
      New Member
      • Aug 2014
      • 17

      #3
      i'm trying to make a username and password form in access 2007. After keeing in the below code, an error message showing "Method or data member not found" what might be the cause?a yellow highlight appears on line 1
      Code:
      Private Sub Command4_Click()
      Username.SetFocus
      If Username = "staff1" And Password = "staff1" Then
      MsgBox "Access Granted", vbInformation, "school system"
      MsgBox "Welcome", vbInformation, "school system"
      DoCmd.Close
      DoCmd.OpenForm "School system"
      Else
      MsgBox "Access denied. Please enter your username and password"
      End If
      End Sub

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32636

        #4
        If the highlight is on line #1 then you need to revisit the link I pointed you to in the first post. It means your code is invalid and won't compile. The link tells you how to proceed.

        Comment

        Working...