Username/Password Form

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.
 
S

Stefan Hoffmann

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 <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top