Share via

Login Code Problem in Access

Anonymous
2018-06-11T14:54:25+00:00

Hello there, please someone should help me on this code problem, I am working on how to login to a form main menu using a login screen to achieve gain access,I have created a table called "Admin" and  a "login form" I created textboxes for "user name and Password" with the following codes:

Private Sub btnLogin_Click()

   Dim rs As Recordset

Set rs = CurrentDb.OpenRecordset("tblAdim", dbOpenSnapShot, DbReadOnly)

   rs.FindFirst "UserName='" & Me.txtUsername & "'"

   If rs.NoMatch = True Then

  Me.lbWrongUser.Visible = True

  Me.txtUsername.SetFocus

Exit Sub

End If

Me.lbWrongUser.Visible = False

 If rs!Password <> Me.txtPassword Then

  Me.lblWrongPass.Visible = True

  Me.txtPassword.SetFocus

    Exit Sub

 End If

  Me.lblWrongPass.Visible = False

  DoCmd.OpenForm "frmMainMenu"

  DoCmd.Close acForm, Me.Name

  End Sub

     But the exception I got is :" user defined type not defined" Please tell me what to do.

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

19 answers

Sort by: Most helpful
  1. Anonymous
    2018-06-11T16:40:13+00:00

    ok! I have just done that

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2018-06-11T16:35:03+00:00

    I have seen it but ms access 15.0 object library is already checked

    That's not the library in question.  Yes, that library should be checked, but also the one called "Microsoft Office 15.0 Access database engine Object Library".

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2018-06-11T16:30:55+00:00

    I have seen it but ms access 15.0 object library is already checked

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2018-06-11T16:25:15+00:00

    When you are writing code, such as you posted, you are in the VB (Visual Basic) Editor.

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2018-06-11T16:24:22+00:00

    I have seen the VB Editor

    Was this answer helpful?

    0 comments No comments