Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile Error

Status
Not open for further replies.

spudmizer

Technical User
Jul 25, 2002
35
US
I have a click button with this code

Private Sub cmdOK_Click()
On Error Resume Next
Logon_OK_Cancel

End Sub

However when i click the button I get this
Compile Error: Expected Variable or Procedure; not module.

I need it to run Logon_OK_Cancel which is a module, so How do I tell it to do it ??
 
at a guess I'd say it means just that "Expected Variable or Procedure" so specify a procedure within the module.
 
Ok so what am I looking for ??
Here is the code


Private Sub Logon_OK_Cancel()
On Error Resume Next
' declare string variables for messages
Dim strMsg As String, strTitle As String
'if the ok button is clicked and there's missing info,
'let the user know and start again.
If IsNothing(Me!txtUserID) Or IsNothing(Me!txtPassword) Then
strMsg = "Please enter a Valid User ID and Password."
strTitle = "Login"
MsgBox strMsg, vbCritical, strTitle
Me!txtUserID.SetFocus
Exit Sub
End If
'we've got this far, so the user has input an ID and password.
'copy their details to the local PC.
DoCmd.SetWarnings False ' no need to tell me a query is being run
DoCmd.OpenQuery "qryUsersLocal" 'run the query
DoCmd.SetWarnings True ' tell me next time a query is being run


'making the local table now, greatly speeds up these DLOOKUPS
'check that the user exits
If IsNull(DLookup("[Title]", "tblUsersLocal", "[UserID] = Form.[txtUserID]")) Then
strMsg = "User ID is Invalid, Please try again."
strTitle = "Invalid User ID"
MsgBox strtMsg, vbCritical, strTitle
Me!txtUserID.SetFocus
Exit Sub
End If

'check that their password is correct
If Not DLookup("[Password]", "tblUsersLocal", "[UserID] = Form.txtUserID") = Forms![frmLogin]![txtPassword] Then
strMsg = "Password is Invalid, Please try again."
strTitle = "Invalid Password"
MsgBox strtMsg, vbCritical, strTitle
Me!Password.SetFocus
Exit Sub
End If
'the user exists and their password is correct
Me.Visible = False ' hide the frmLogin but don't unload it.
DoCmd.OpenForm "Your Splash Screen" 'open or show your splash screen
End Sub
 
aah, is the above code in a different module to your onclick event? if so you might want to declare the logon_ok_cancel sub as private rather than public
 
Ok I took to to my onclick event and it worked, However it doesn't get pass the first set or error code, its not reconizing that anything was enter??


If IsNothing(Me!txtUserID) Or IsNothing(Me!txtPassword) Then
strMsg = "Please enter a Valid User ID and Password."
strTitle = "Login"
MsgBox strMsg, vbCritical, strTitle
Me!txtUserID.SetFocus
Exit Sub
End If
All this is checking for is if the fields are empty ??? But I am enter data !!!
 
sorry hadn't read that far into your code otherwise would have spotted this, your using Me and this code doesn't live in the form module, so if you specifically reference the form that should sort it out.

e.g.

If IsNothing(FormName.txtUserID) Or IsNothing(FormName.txtPassword) Then
strMsg = "Please enter a Valid User ID and Password."
strTitle = "Login"
MsgBox strMsg, vbCritical, strTitle
Me!txtUserID.SetFocus
Exit Sub
End If
 
Never Mind I found out what was wrong...did name the tet field correctly !!!

However now it ask me to: Enter Parameter Value
Forms!frmLogin!txtUserID

I don't know why its even doing that ???!!??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top