How do I cancel a command?

Noreene Patrick

Registered User.
Local time
Yesterday, 21:13
Joined
Jul 18, 2002
Messages
223
My form has a command button that employees can click to get current efficiency....The command button runs a query and opens a form that shows their name and efficiency with a command button to go back to original form. However, if they put in the wrong id # or hit a + sign or something foreign, it cannot query because the id number is incorrect so it gives them the form without anything on it...it doesnt even have the button to go back to original form...they cant get back.

So, right now the code behind the on click event of the button says:

Private Sub cmdcheckminutes_Click()
DoCmd.OpenForm "frmindividualorderminutes"
end sub

How do I tell it to cancel the command if the id number is incorrect ? (I dont want it to even open the form.)

Also, when the "individualorderminutes" form closes to go back to original form, I want the focus set on me.pickerid field...I couldnt figure out how to reference that field from another form..

Thanks, Noreene
 
Use DLookUp to verify the entry exists, or use a combo box to select the correct number
 
Noreene Patrick said:
My form has a command button that employees can click to get current efficiency....The command button runs a query and opens a form that shows their name and efficiency. . .

How do you stop employees looking up other peoples efficiency?

Col
 
Thanks Rich, I will give it a try


ColinEssex:
I dont have a way to keep employees from looking up other efficiencies....if they know the employees' id # they can look up someone elses...

Any suggestions?
 
If you can get their system ids into a table you can do a check on them to ensure that they are accessing only their own.

i.e.

Code:
If Environ("username") = Nz(DLookup("UserName", "tblUsers", "UserID = """ & Me.txtUserID & """"), "Unknown") Then
    Msgbox "Allowed to view"
Else
    Msgbox "Not allowed to view"
End If
 

Users who are viewing this thread

Back
Top Bottom