Code in a sub form

Jade

Registered User.
Local time
Today, 18:13
Joined
Jun 15, 2001
Messages
24
I have a form and a sub form and I need to write an If Statement in the subform. If someone chooses an item from a drop down list say "field 1", I need to force the user to input data into one other field say "field 2". How is this done?

Thank you for your help
 
Jade,

This depends on the location of the controls. If both are on the subform then it's pretty simple. Attached to the subform's BeforeUpdate property would be a few lines like;
If IsNull(Me.Field2) Then
MsgBox "Please complete field 2"
Cancel = True
End If
The Cancel = True statement will stop the record from updating until something is placed in Field 2.
If Field 1 is on the main form and field 2 on the sub form then it gets a little trickier. eg. If the sub form lists multiple records against the main form. Different strategies would be employed depending on your needs.

Jon
 

Users who are viewing this thread

Back
Top Bottom