Username/Password Form

  • Thread starter Thread starter Todd C
  • Start date Start date
T

Todd C

I have created a form with a combo box that contains the names of all users,
and a textbox for the password field. A couple years ago, I was shown a way
to get rid of the combo box so that users would have to type in their
username. i have attempted it over and over, but each time, it either will
not work at all, or will find the record, but if the password is entered
wrong, it wont be able to find it again. If anyone can help, I would really
appreciate it.
 
hi Todd,

Todd said:
I have created a form with a combo box that contains the names of all users,
and a textbox for the password field. A couple years ago, I was shown a way
to get rid of the combo box so that users would have to type in their
username.
Something like this:

Private Sub btn_Click()

Dim rs As DAO.Recordset
Dim SQL As String

SQL = "SELECT * " & _
"FROM User " & _
"WHERE Username = " & SQLQuote(AUsername) & " " & _
"AND Password = " & SQLQuote(APassword)
Set rs = CurrentDb.OpenRecordset(SQL, dbOpenSnapshot)
If Not rs.Bof And Not rs.Eof Then
' valid credentials
Else
' invalid credentials
End If

End Sub

Public Function SQLQuote(AString As String, _
Optional ADelimiter As String = "'" _
) As String

SQLQuote = ADelimiter & _
Replace(AString, ADelimiter, ADelimiter & ADelimiter) & _
ADelimiter

End Function


mfG
--> stefan <--
 
Back
Top