Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Simple passwords (xp)

    I have a two column table, one column houses a staffid number, the other a password. On opening the database, a form opens containing 2 text boxes and the user is prompted to enter his staffid and password. I need a query that compares these values with those in the table. Any suggestions would be appreciated.
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

  2. #2
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Simple passwords (xp)

    Many thanks, Hans. Long time no post!
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

  3. #3
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Simple passwords (xp)

    Hi Hans. Typed in the procedure substituting my names and it worked once. On subsequent attempts I get an error message stating there was an error evaluating the procedure. Any ideas?
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Simple passwords (xp)

    I hope you caught the obvious typo MagBox for MsgBox? (Corrected in my previous reply now) Otherwise, I wouldn't know. Can you find out where the error occurs?

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Simple passwords (xp)

    Corrected typo in code: MagBox should have been MsgBox.

    Why a query? You can use the DLookup or DCount function. Say that the text boxes are named txtStaffID and txtPassword, and that you have a command button cmdOK on the form. The On Click event procedure could look like this:

    Private Sub cmdOK_Click()
    Dim lngCount As Long
    lngCount = DCount("*", "NameOfTable", _
    "[StaffID] = " & Me.txtStaffID & " And [Password] = " & _
    Chr(34) & Me.txtPassword & Chr(34))
    If lngCount = 0 Then
    ' No match - warn user
    MsgBox "The StaffID - password combination you entered is not valid."
    Else
    ' It's OK
    ' code to continue after logging in goes here
    End If
    End Sub

    Substitute the correct table and field names. I have assumed that StaffID is numeric and Password is text.

Posting Permissions

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