Problems with login code

Phonik

Registered User.
Local time
Today, 18:23
Joined
Sep 22, 2006
Messages
111
Hi,

I have created the following code to use on a login screen but when used under a runtime environment causes runtime error and is giving me a headache.

CODE:

Private Sub Command7_Click()


On Error GoTo Err_Command7_Click

Dim Value As Variant
Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.SetWarnings (WarningsOff)

Value = DLookup("[ID]", "Tbl_users", "[ID] = '" & Forms![Frm_login]![User ID] & "' and [Password] = '" & Forms![Frm_login]![Password] & "'")

If Value = Forms![Frm_login]![User ID] Then

stDocName = "Frm_main_menu"
DoCmd.OpenQuery "Qry_know_logged_in_users"
stLinkCriteria = "[ID]=" & "'" & Me![User ID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Forms![Frm_login].Visible = False

Else
DoCmd.OpenForm "Frm_login_error"

End If

Exit_Command7_Click:
Exit Sub

Err_Command7_Click:
MsgBox Err.Description
Resume Exit_Command7_Click


End Sub

Can anyone see where I am going wrong here?

Many thanks! Your all stars!
 
What is the specific run-time error message you are receiving? To get better specifics, change your error-trap code to:
Code:
MsgBox Err.Number & " : " & Err.Description
 
problems with login code

Try after removing square brackets around ID in dlookup() Function.
 
try this

DoCmd.SetWarnings (WarningsOff)

probably should be

DoCmd.SetWarnings (false)

you ought to set it back to true somewhere.

----------------------
you must be getting an unusual error of some sort, as you are trapping the trappable errors.
 
The part about the brackets [] worked a treat. Thats what it was..or a combination of that and the setwarnings thing. Thanks so much.
Only another 60 ish forms to go now. I feel a few more posts coming on...

Thanks again

Gaz
 

Users who are viewing this thread

Back
Top Bottom