• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1079
  • Last Modified:

MS Access - BeforeUpdate for form validations

In an Access database, I am trying to use the BeforeUpdate event, specifically the Form_BeforeUpdate sub, to validate the row, then set Cancel if it fails so the row is not posted to the DB. The problem is in addition to being run before the row is posted, Form_BeforeUpdate is run after the field is updated, and I can't tell if the user updated a field & tabbed out, or if the user attempted to leave the row & post it to the DB.

How can I tell if the Form_BeforeUpdate is being run as after as field level validation or as a row level validation?

Thanks in advance,
parkerea
0
parkerea
Asked:
parkerea
1 Solution
 
MikeTooleCommented:
The Form_BeforeUpdate event only runs immediately before the data is posted. However, with the default settings, the update will be posted when the user tabs out of the last control on the form. To change this behaviour, set the form's Cycle property  to Current Record instead of All Records. Tabbing out of the last control will then take the user to the first control on the same record - rather than the first control on the next record, which is what is causing the Form_BeforeUpdate event to be triggered.
Hope this helps
0
 
parkereaAuthor Commented:
That is actually what I thought, but I found the problem: this form was developed by someone else and it has some stuff that I did not know was there. One of the fields was calling a macro on the "After Update" event, and that macro had RunCommand / SaveRecord in it, so it was that macro that was triggering the call to the form's Form_BeforeUpdate() sub. It made it LOOK like changing & tabbing out of that field was calling Form_BeforeUpdate().

Thanks again,
parkerea
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now