Results 1 to 8 of 8

Thread: Treypick

  1. #1
    Join Date
    Oct 2010
    Posts
    7

    Unanswered: Treypick

    I have a database with 3 tables. One table is named users, one is named auth, and the other is named password. I am trying to build a login form with 3 fields, User name, Auth, and Password. I want to type the info in each field. The hope is not to be forced to use a combo box. Just about any sample code that I have found downloads with an mdb extension. I am using access 2010 with database extension accdb. Any help in finding code for a login form or suggestions will be very much appreciated. As you can tell I am just learning access

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    For starters, why do you have 3 tables? It sounds like you'd want a single "Users" table, which would include fields for the user's password and auth (which I assume is some sort of authorization level). In any case, the same code you've found in MDB samples should also work in ACCDB format.
    Paul

  3. #3
    Join Date
    Oct 2010
    Posts
    7

    Treypick

    I misspoke regarding the tables. I have 1 table with 3 categories. The following code is from an mdb format file. It works in the original mdb format file but not in the accdb format. The little menu has 2 unbound fields and I am using a control to implement the code?????

    Option Compare Database

    Private Sub CancelButton_Click()

    End Sub

    'Private Sub CancelButton_Click()
    'DoCmd****nCommand acCmdExit
    'End Sub

    Private Sub okButton_Click()
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    If IsNull(Me.UserTxt) Then
    MsgBox "Please enter a valid user name.", vbExclamation, "Error"
    Me.UserTxt.SetFocus
    Exit Sub
    ElseIf IsNull(Me.PassTxt) Then
    MsgBox "Please enter a valid password.", vbExclamation, "Error"
    Me.PassTxt.SetFocus
    Exit Sub
    End If
    rs.Open "SELECT * FROM tblUser WHERE(UserName = """ & Me.UserTxt & """ AND Pass = """ & Me.PassTxt & """)", _
    CurrentProject.Connection, adOpenKeyset, adLockOptimistic
    If rs.EOF Then
    MsgBox "Invalid user name or password. Please try again.", vbExclamation, "Error"
    Me.UserTxt.SetFocus
    Exit Sub
    End If
    MsgBox "Login Successful.", vbInformation, "Confirm!"
    DoCmd.Close
    Exit Sub
    End Sub

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Can you be more specific when you say it doesn't work? Do you get an error? If so, what is it, and on what line?
    Paul

  5. #5
    Join Date
    Oct 2010
    Posts
    7
    Paul,
    It does nothing at all. It would seem without a doubt I am not coding the button correctly.

  6. #6
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    2007 has some security features. Is any code running at all? If not, make sure the database is in a Trusted Location (Office Button/Access Options/Trust Center/Trust Center Settings) or that you've explicitly enabled code (option on the menu bar).
    Paul

  7. #7
    Join Date
    Oct 2010
    Posts
    7

    Access Login Problem "Treypick"

    Paul,

    I sincerely thank you for you help. The problem is resolved. I must admit that the dumb machine out-smarted me.

  8. #8
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Happy to help, and welcome to the site by the way. In the future, a more descriptive thread title will help people searching the site for answers to their questions.

    I'm not so sure that they're dumb machines. I think they're diabolically clever machines whose sole purpose in life is to screw with our heads.
    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •