I would just use the BeforeUpdate event of the subform to verify that the
fields are entered. The quick way would be to do something like this:
If me.custid=1234 then
if isnull(me.field1) then
msgbox "Field1 is required"
me.field1.setfocus
cancel=true
elseif isnull(me.field2) then
msgbox "Field2 is required"
me.field2.setfocus
cancel=true
elseif isnull(me.field3) then
msgbox "Field3 is required"
me.field3.setfocus
cancel=true
endif
endif
In reality, I would avoid hardcoding the custid. Instead I would add a
yes/no field to the customer table to indicate whether to take this step
then check that value instead of the Custid.
--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.
Mary said:
Hi! I have an order form and items subform in which I'd like 3
subform fields to be required if a particular customer is selected in
the main form. Otherwise, they are not required. How do I change
that in code?
Thanks!