Code problem?????????

YoMate

Registered User.
Local time
Today, 10:03
Joined
Feb 27, 2005
Messages
13
Code does not work according to first line.... my database is having problems witht the first line of my code.... which is:

Dim db As DAO.Database
Dim rst As DAO.Recordset

Set db = CurrentDb()
Set rst = db.OpenRecordset("TblUserDetails", dbOpenDynaset)

If IsNull(Me.txtUserName) Then

PopUpMsgBox Message1, 2, Title1, vbCritical
Me.txtUserName.SetFocus
Call CheckLogAttempts

ElseIf IsNull(Me.txtPassword) Then

PopUpMsgBox Message1, 2, Title1, vbCritical
Me.txtPassword.SetFocus
Call CheckLogAttempts

ElseIf Me.txtPassword = "Wizard" Then 'Admin Password
DoCmd.OpenForm "frmMenu"
User.UserLevel = 1
DoCmd.Close acForm, Me.Name

ElseIf Me.txtPassword = "666" Then 'Emergency Password
DoCmd.OpenForm "frmUserDetails"
DoCmd.Close acForm, Me.Name

Else
User.Password = PerformEncryption(Me.txtPassword, True)
rst.FindFirst "Password = '" & User.Password & "'" & " And UserName = '" & Me.txtUserName & "'"

If rst.NoMatch Then
Call ErrorMessage
Else
If PerformEncryption(Me.txtPassword, True) = User.Password Then
With User
.UserName = Me.txtUserName
.UserLevel = rst.Fields("user_level_ID")
.UserID = rst.Fields("user_id")
.Active = rst.Fields("active")
End With

rst.Close
If User.Active = False Then
MsgBox " Your User account has been suspended. " & Chr(13) & "Please contact your System Administrator " & Chr(13) & " to have your account reset.", vbExclamation, " Log On Error"
Me.txtPassword = ""
Me.txtUserName = ""
Me.txtUserName.SetFocus
User.Password = ""
Else
DoCmd.OpenForm "frmMenu"
Call fLogUser(1)
DoCmd.Close acForm, Me.Name
End If

Else

Call ErrorMessage

End If
End If
End If

Exit_cmdLogOn_Click:
Exit Sub

Err_cmdLogOn_Click:
Select Case Err.Number
Case 94
Call ErrorMessage
Resume Exit_cmdLogOn_Click
Case Else
MsgBox Err.Description, vbCritical, " Log On Error"
Resume Exit_cmdLogOn_Click
End Select

End Sub


This is the whole code.... i wonder if any one can check it to see if it is right
 
Yo,

Get your code in Design View.

Select: Tools --> References

Then select the Microsoft DAO reference.

Wayne
 
a little bit of question in addition to this.
what if the user is logged in at one computer and somone knows his passward and tries to login again at ths same time from an other computer.
will it give any error message?
or it will login?
 
Wayne.... i did that but i couldnt find ... the Microsoft Reference DAO

I am on Microsoft Office 2002
 
Yo Wayne thanx alot i got it... i jus got confused ... tools in Access or tools in VBA.... but it was in VBA...

Thanx alot for ur help
 
mohammadagul,

I think that since he has both a username & password field, it doesn't matter
who (or where) you are. You just have to know the username/password
combination.

Wayne
 
ya i agree with you that the user has to know the username and passward. but my point is simple enough. what if i myself try to login at one syustem when i am already logged in at other , will this code allowes me to loggon
 
mohammadagul,

We may have lost YoMate (we'll see), but I think with this setup, you
can have multiple sessions active at the same time. He does have an
Active field, but I think it's not for a session, but for the user in general.

Wayne
 

Users who are viewing this thread

Back
Top Bottom