B
Beth
I posted a few days ago with an issue updating on a form. The original post
and reply are below.
It worked perfectly while I had a message box popup after the "end with "
statement (so I could see it stepping through.)
Once I removed the message box, the errors started. The field they will be
updating to create the before insert event is a combo box with an after
update event. If I remove the message box, the code to set a recored in the
parent form works, but the value in the field is cleared and the after
update event doesn't trigger. If I have the message box in the code, the
code to add the parent form works, the value stays in the field, and the
after update event triggers perfectly.
Why would the message box be so important in the steps and how can I remove
it and still make everything work fine?
The message box statement is very simple.... msgbox("end of add parent
form")
Thanks,
Beth
since the date field in the main form has a default value anyway, suggest
you remove the DefaultValue setting, and add it via code in the subform. try
adding the following code to the *subform's* BeforeInsert event procedure,
as
With Me.Parent
If .NewRecord Then
!aDate = <the default date value>
.Dirty = False
End If
End With
"Parent" refers to the subform object's parent object, which is the main
form. adding the date value triggers the Autonumber primary key, and setting
the main form's Dirty property to False saves the record to disk, so the PK
value is available to the subform record.
hth
and reply are below.
It worked perfectly while I had a message box popup after the "end with "
statement (so I could see it stepping through.)
Once I removed the message box, the errors started. The field they will be
updating to create the before insert event is a combo box with an after
update event. If I remove the message box, the code to set a recored in the
parent form works, but the value in the field is cleared and the after
update event doesn't trigger. If I have the message box in the code, the
code to add the parent form works, the value stays in the field, and the
after update event triggers perfectly.
Why would the message box be so important in the steps and how can I remove
it and still make everything work fine?
The message box statement is very simple.... msgbox("end of add parent
form")
Thanks,
Beth
since the date field in the main form has a default value anyway, suggest
you remove the DefaultValue setting, and add it via code in the subform. try
adding the following code to the *subform's* BeforeInsert event procedure,
as
With Me.Parent
If .NewRecord Then
!aDate = <the default date value>
.Dirty = False
End If
End With
"Parent" refers to the subform object's parent object, which is the main
form. adding the date value triggers the Autonumber primary key, and setting
the main form's Dirty property to False saves the record to disk, so the PK
value is available to the subform record.
hth