Stop subform saving until I leave the record

  • Thread starter david epsom dot com dot au
  • Start date
D

david epsom dot com dot au

I have a subform linked by master/child fields to a main form.

This is not how I usually code, and I'm not used to it.

Immediately after I start to enter data into a new record, I get a before
update event, and Access tests the validity of some of the fields on the
subform. That is far two early - the record is not complete.

It doesn't really save the record, because I can still escape out of the new
record.

When I don't use master/child fields, I don't get this error (and I don't
get default values automatically inserted into those fields).

The actually error is something like "The datYield can't be null, because
it is a required field". I know that, I just have not entered that field
yet.

I can capture and ignore the data error in the form error event, but am I
doing something wrong?

Is there something about locking or default values or primary keys that
avoids this nonsense?

(david)
 
A

Allen Browne

David, any chance that:
a) This subform is based on a multi-table query, and
b) There is a Default Value in one of the fields of a lookup table?

There is a scenario similar to what you describe. Access gets confused by
the Default Value in the lookup table's field (or in the Default Value
property of a control bound to the lookup table.) You are not actually
attempting to add a record to the lookup table, but it does not understand
that.

The error typically triggers on the first keystroke of the new entry in the
subform. Removing the Default Value should solve the problem if this is the
scenario.
 
Top