form events

  • Thread starter Thread starter JulieD
  • Start date Start date
J

JulieD

having trouble trying to decide which form event to use -
i have a multi-tab form - the second tab is called "Workplaces" and contains
a continuous sub-form called sFRM_Workplaces.

what i want to do is to check that only one 'date to' field is blank, ie
they can't be listed in two workplaces at the same time, and they must have
a current workplace listed.

i can do this using the AFTERUPDATE event of the form by counting the number
of records with null dateto fields for the student.

i then advise the user that they have a problem - and this is where i also
have a problem -
1) i can't seem to return the focus to the subform if they click on another
tab after changing data
and
2) if they then just ignore the message and move to another tab the message
doesn't fire again as AFTERUPDATE only works if data has been changed

is there a better way to achieve what i want to do?

regards
JulieD
 
Use the Form_BeforeUpdate event of the subform.

Use DCount() to get the number of *other* records in the subform's table
where the [Date to] field is null. If there is another and this one is blank
also, cancel the event if you wish to prevent this one being saved.
 
Back
Top