Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Oct 2004
    Location
    Evansville, Indiana, USA
    Posts
    111
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Password Verification (2000)

    I have a login screen that has a password field. I have an Employee table with several fields including Last Name and Password. How do I match the last name selected with the password input?

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

    Re: Password Verification (2000)

    You can use (for example) DLookup. I assume that you have an OK button on the form or something similar. In the On Click event procedure of the OK button, you can test like this:

    Private Sub cmdOK_Click()
    Dim varPwd
    If IsNull(Me.txtLastName) Then
    MsgBox "Please enter a last name."
    ElseIf IsNull(Me.txtPassword) Then
    MsgBox "Please enter a password."
    Else
    varPwd = DLookup("Password", "Employee", "LastName = " & Chr(34) & Me.txtLastName & Chr(34))
    If IsNull(varPwd) Then
    MsgBox "Last name not found."
    ElseIf varPwd <> Me.txtPassword Then
    MsgBox "Wrong password for last name."
    Else
    ' Password OK - insert code here
    End If
    End If
    End Sub

  3. #3
    2 Star Lounger
    Join Date
    Oct 2004
    Location
    Evansville, Indiana, USA
    Posts
    111
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Password Verification (2000)

    I forgot to tell say that on the login form I have:
    SELECT [Employee].[last name] & " " & [Employee].[first name] AS FullName FROM Employee ORDER BY [Employee].[last name] & " " & [Employee].[first name];
    to concatenate the last mane with the first name so they both will display in the combo box. But they are separate fields in the table.

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

    Re: Password Verification (2000)

    Do you also have an EmployeeID or something like that? That would be much more convenient to use: include it in the row source of the combo box (I presume that's what you're talking about):.

    SELECT [Employee].[EmployeeID], [Employee].[last name] & " " & [Employee].[first name] AS FullName FROM Employee ORDER BY [Employee].[last name] & " " & [Employee].[first name];

    but hide it by setting the first column width to 0 (and column count to 2). In my example code, the line

    varPwd = DLookup("Password", "Employee", "LastName = " & Chr(34) & Me.txtLastName & Chr(34))

    would become

    varPwd = DLookup("Password", "Employee", "EmployeeID = " & Me.cbxEmployee)

    where cbxEmployee is the name of the combo box.

  5. #5
    2 Star Lounger
    Join Date
    Oct 2004
    Location
    Evansville, Indiana, USA
    Posts
    111
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Password Verification (2000)

    I did what you said and here is the message I get:
    Run-time Error '3075'
    Syntax error in date in query expression 'Emp# = A170"
    A170 is the correct emp# for the name I selected.
    Thanks
    BMZ

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

    Re: Password Verification (2000)

    I had assumed that you had a numeric Employee ID. Re-introduce the Chr(34)'s:

    varPwd = DLookup("Password", "Employee", "[Emp#] = " & Chr(34) & Me.cbxEmployee & Chr(34))

    of course, with the correct name for the combo box substituted.

  7. #7
    2 Star Lounger
    Join Date
    Oct 2004
    Location
    Evansville, Indiana, USA
    Posts
    111
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Password Verification (2000)

    That works great. For future reference, what does the chr(34) do?

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

    Re: Password Verification (2000)

    Chr(34) is equivalent to a double quote ". You must surround text values with quotes, but you cannot just use ", since that would be interpreted as the end of the string. One way around it is to double the double quotes, another way is to use Chr(34).

Posting Permissions

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