[AccessD] Data Validation on Form - A97

Mcgillivray, Donald [LTD] donald.a.Mcgillivray at mail.sprint.com
Thu Mar 27 12:29:23 CST 2003


Ok, I guess I really am clueless.

I'm trying to intercept control values on a form prior to their being pushed
to the underlying table so I can validate user entries and display my own
error message and prompt for re-entry if necessary.  

I have a VERY simple bound form/subform.  The main form has only two
controls: txtPersonID and txtDate (bound to their respective fields) the
combination of which defines a unique index in the underlying table; the
subform contains the child records for the person/date combination specified
on the main form.

I've put code in the BeforeUpdate events of both the form and the date
control (separately - not at the same time), and so far have been unable to
get my code to fire when deliberately violating the person/date index rule.
Instead, I get the default warning (from Jet, I think?) about the new record
violating the table's indexing rules.  I guess the record is getting pushed
to the table BEFORE the BeforeUpdate event fires.  Access then takes over,
testing the validity of the entry and sending its own message, which (I
promise) will only confuse my users.  I have also tried using the form's
BeforeInsert event, but that causes my code to fire at the first keystroke
on the clean form (before there's any data to validate.)

Obviously, I'm misunderstanding the use of these events for validation, or
I'm adopting an incorrect strategy for dealing with this issue.  Anybody out
there willing to escort me out of the woods or offer alternative solutions?

Thanks!


More information about the AccessD mailing list