VB Login Help!

Lakhvir

Registered User.
Local time
Today, 05:36
Joined
Mar 9, 2012
Messages
46
Hii,

I am currently trying to produce some code that can be used on a login form within my database. How do I make it so that the login will accept multiple usernames and passwords? There are a couple of member login details stored in the tblLogin, however I don't know how to code it for this. It works when I hardcode a username and password into the code, but how do I make it so that it accepts more than one username and password?

Here is the code I have

Code:
Private Sub cmdSubmit_Click()

If txtUsername = "Jon.Hughes" Then
If txtPassword = "Password" Then
DoCmd.Close
DoCmd.OpenForm ("frmHomepage")
MsgBox ("You Have Successfully Logged In.")
Else
txtUsername = ""
txtPassword = ""
MsgBox ("Incorrect. Please Try Again.")
End If
Else
txtUsername = ""
txtPassword = ""
MsgBox ("Incorrect. Please Try Again.")
End If
End Sub

Could do with some guidance and help urgently!

Many thanks.
 
Typically you'd have a table with user name and password fields. You'd use a recordset or domain aggregate function to check the password against what the user entered. For instance

If DLookup(...) = Me.txtPassword Then
 
Hi, I have next to no experience in VB so could with some more help please.
I have a table called tblLogin. This stores usernames and passwords. Such a noob here :(
 

Users who are viewing this thread

Back
Top Bottom