in re: control's BeforeUpdate event
Having said that, this is something I use only rarely. Mostly, I
prefer to do all the validation in Form_BeforeUpdate. I think
people find it less annoying if they get the chance to fix a silly
thing themselves, and only handle one message box if things are
not right. (Additionally, Form_BeforeUpdate is the only event to
compare fields, and to test for nulls.)
I think it makes sense to validate entry when it's happening. That
means choosing an appropriate control type in the first place. If a
field can only have a limited number of values, an option group or a
combo box or listbox are the appropriate control type.
If it's a date field, Access date handling will prevent the entry of
an invalid date, but it won't prevent you from entering nonsensical
dates (such as 12/15/208 instead of 12/15/2008). For that, you can
use an input mask or logic in the BeforeUpdate event. I have
something of a love-hate relationship with input masks -- I hate
them myself, but users don't seem to mind them at all, since they
take away any need for them to think about what they are supposed to
enter.
I wouldn't leave something like that to a form-level event. Indeed,
I wouldn't leave cross-field comparisons to a form-level event,
because I think it's extraordinarily annoying to enter a bunch of
data and then after your focus has moved on from entering each piece
of information, to be informed of an error in the data. Say you're
entering data from a paper form. If you get the validation message
at the time you enter one piece of data, you should immediately be
able to scan back to the exact same location on the paper form to
check what you should have typed. If the validation is left to the
end, you have to rescan the whole page and relocate each individual
piece of data.
I can see situations where groups of fields should definitely be
validated together, but in that case, I'd like use a wizard-type
interface, with data fields entered in small groups, with <<Previous
and Next>> buttons, and the Next>> button would not be enabled until
the data in the current set of fields is valid and internallly
consistent.