I am trying to create a general Log In Screen for Access 2007 using VBA code. My front Form has been named frmLogIn. Within this form contains the two text fields txtUserName and txtPassword. I have a cmdClose button along with a cmdLogIn button. And if logged in successfully it goes to a Form called frmTrackingCosts So it looks like this:
User Name: [txtUserName]
cmdLogIn=[Log In] cmdClose=[Close]
Now I have a table called tblLogIn within this table contains 2 fields one being UserName and the other is Password.
Example of what my table shows:
How would I go about (using VBA) having a cmdLogIn button click event where when clicked it will go through the tblLogIn Table and find if the User Name that you typed and the password are in the table and if not let the User Know that.
Here is what I have so far what am I missing????:
Private Sub cmdLogIn_Click()
If IsNull(Me.txtUserName) Or Me.txtUserName="" Then
MsgBox "Please Make sure to fill in a User Name"
If IsNull(Me.txtPassword) Or Me.txtPassword="" Then
MsgBox "Please Make sure to fill in a Password"
If Me.txtPassword.Value = DLookup("Password", "tblLogIn", [UserName] = """ & Me.UserName.Value & """) Then Then
DoCmd.Close acForm, "frmLogIn", acSaveNo