By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,132 Members | 1,417 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,132 IT Pros & Developers. It's quick & easy.

Help for making a login page via Microsoft Access

P: n/a
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

Nov 22 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
If Me.txtPass.Value = DLookup("password", "tblLogin", "[loginID] =" &
Me.txtUser.Value)

should be:

If Me.txtPass.Value = DLookup("password", "tblLogin", "[username]='" &
Me.txtUser.Value & "'")
The problem was that you were comparing the username that was inputted
to the userid (autonumber).

Cheers,
Jason Lepack
ph*******@gmail.com wrote:
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
Nov 22 '06 #2

P: n/a
I tried your code but the message error is still the same.

Nov 22 '06 #3

P: n/a
I m happy to send any helpers my database file. I m just stuck at the
login button function T.T . The hour of my assignment is drawing near.

Nov 22 '06 #4

P: n/a
If Me.txtPass.Value = DLookup("password", "tblLogin", "[username]='" &
Me.txtUser.Value & "'")
The problem was that you were comparing the username that was inputted
to the userid (autonumber).
Cheers,
Jason Lepack
ph*******@gmail.com wrote:
I m happy to send any helpers my database file. I m just stuck at the
login button function T.T . The hour of my assignment is drawing near.
Nov 22 '06 #5

P: n/a
i have tried, doesnt work :'(

Nov 26 '06 #6

P: n/a
sorry mate, it works now. thanks for all the help. Cheer

Nov 26 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.