I'm trying to figure out how to write code that will prevent data entry clerks from using the wrong form. Background: The table has an id number which is the primary key [field1]. It also has a field with a pull-down menu for two options (Option 1 and Option 2) [field2] There are two different forms for each option. Both forms are dependent on a query. In both queries, I have the following criteria set for the id number: Like[enter ID number] so that only one record comes up. If a record for user ID 2222 contains the choice of Option 2 for [field 2], I want an error message to be displayed if the form for Option 1 is selected, and I want the form to close.
I believe the code would go in the On Open property field of the form. I think it would be something like (not including syntax):
If [field2] <> "Option 1" for [userID] (number that was entered by user) Then
Private Sub strMessage "You have either chosen the form for Option 1 by mistake, or the option for the student ID that was entered contains the incorrect option. Please choose the correct form or change the option for this student in the first entry form."
(give an OK button that triggers the form to close)
End If
As you can tell, I'm not a VBA programmer, although I manage to muddle through some VBA code. I would greatly appreciate any help. Thanks.
I believe the code would go in the On Open property field of the form. I think it would be something like (not including syntax):
If [field2] <> "Option 1" for [userID] (number that was entered by user) Then
Private Sub strMessage "You have either chosen the form for Option 1 by mistake, or the option for the student ID that was entered contains the incorrect option. Please choose the correct form or change the option for this student in the first entry form."
(give an OK button that triggers the form to close)
End If
As you can tell, I'm not a VBA programmer, although I manage to muddle through some VBA code. I would greatly appreciate any help. Thanks.