Referencing the 'Phantom' Record

J

Jay

Is there a way to reference the "new record" row at the bottom of a form in
datasheet view and reset a value for one of its fields ?

I have a properly working procedure that resets the DefaultValue property
for a form's checkbox field in new records, but that checkbox field in the
blank "new record" row that existed at the time the procedure runs remains
unchanged. Need to change it, too, so that when a user uses the blank row to
add a new record, that checkbox's value is properly pre-set.
 
M

Marshall Barton

Jay said:
Is there a way to reference the "new record" row at the bottom of a form in
datasheet view and reset a value for one of its fields ?

I have a properly working procedure that resets the DefaultValue property
for a form's checkbox field in new records, but that checkbox field in the
blank "new record" row that existed at the time the procedure runs remains
unchanged. Need to change it, too, so that when a user uses the blank row to
add a new record, that checkbox's value is properly pre-set.


The DefaultValue property is applied to a new record on the
first keystroke in any bound control. I.e. changing the
DefaultValue has no effect on a new record that is dirty.

Your current code will work fine in every case except when
the current record is dirty and it is also a new record. In
this one case, you should either Undo the unsaved new record
or set the control's Value property inaddition to its
DafaultValue.

Me.chkbox.DefaultValue = True 'or False
If Me.NewRecord And Me.Dirty Then
Me.chkbox = True 'or False
End If
 
Top