B
BruceM
I have a Purchase Order database that generally seems to be working as
intended, but I have run into a wall on an aspect of data validation. The
PO record is in the main table, with the LineItems in a related table. The
user interface is a main form with a subform. It's a standard set-up for
such things.
I would like to assure that users select at least one line item. If they do
not, the PO record is undone in code. The problem is that clicking into (or
otherwise entering) the line items subform causes the main form's Before
Update code to run. There are no line items yet, so the validation fails,
and a message tells the user they must enter line items when they were in
fact about to do that very thing.
My question is whether anybody can think of a way to enforce the requirement
that there be at least one line item, but still allow the user to enter the
subform (and thereby save the main form record) in order to add a line item
record.
If there was such a thing as a Record Change event that would do the trick.
The validation code would not run until navigating to a new main form
record. Clicking into the subform would not cause the code to run.
I have been experimenting with using a Boolean. If it is false the
validation code does not run; if it is true the code runs. However, even
assuming this is a reasonable approach I have not figured out when to toggle
the value.
intended, but I have run into a wall on an aspect of data validation. The
PO record is in the main table, with the LineItems in a related table. The
user interface is a main form with a subform. It's a standard set-up for
such things.
I would like to assure that users select at least one line item. If they do
not, the PO record is undone in code. The problem is that clicking into (or
otherwise entering) the line items subform causes the main form's Before
Update code to run. There are no line items yet, so the validation fails,
and a message tells the user they must enter line items when they were in
fact about to do that very thing.
My question is whether anybody can think of a way to enforce the requirement
that there be at least one line item, but still allow the user to enter the
subform (and thereby save the main form record) in order to add a line item
record.
If there was such a thing as a Record Change event that would do the trick.
The validation code would not run until navigating to a new main form
record. Clicking into the subform would not cause the code to run.
I have been experimenting with using a Boolean. If it is false the
validation code does not run; if it is true the code runs. However, even
assuming this is a reasonable approach I have not figured out when to toggle
the value.