I m trying to make a login page via Microsoft access. This is my table
..
Table name : tblLogin
PK : loginID(Auto number)
Attributes : username , password.
I make a login form in Microsoft Access which has 2 textfields name :
txtUser and txtPass with a login button name cmdLog . How can i make
the login button works ( open a form call tblMain) when the righ
username and password from the tblLogin are entered?
I had make my attempt by trying someone's code:
Private Sub cmdLog_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.txtUser) Or Me.txtUser = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.txtUser.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPass) Or Me.txtPass = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPass.SetFocus
Exit Sub
End If
'Check value of password in tblEmployees to see if this
'matches value chosen in combo box
If Me.txtPass.Value = DLookup("password", "tblLogin", "[loginID]
=" & Me.txtUser.Value) Then
userName = Me.txtUser.Value
'Close logon form and open splash screen
DoCmd.Close acForm, "frmLogin", acSaveNo
'DoCmd.OpenForm "frmSplash_Screen"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid
Entry!"
'Me.txtPassword.SetFocus
End If
'If User Enters incorrect password 3 times database will shutdown
'intLogonAttempts = intLogonAttempts + 1
'If intLogonAttempts 3 Then
'MsgBox "You do not have access to this database.Please contact
admin.", _
'vbCritical, "Restricted Access!"
'Application.Quit
'End If
End Sub
But in the end i receive a messege of Run-time error '2001': You
canceled the previous operation. When i debug it, it highlights the
line:
If Me.txtPass.Value = DLookup("password", "tblLogin", "[loginID] =" &
Me.txtUser.Value) Then
Please send your help via my email at ph*******@yahoo.com.au .Thanks all