Follow up question to a form/subform issue

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
 
S

strive4peace

DoEvents
---


Hi Beth,

try putting
DoEvents

where your MsgBox was

~~~ DoEvents ~~~

DoEvents is used to make VBA pay attention to what is currently
happening and look to see if the OS (Operating System) has any requests.

ie: if you have a loop and want to be able to BREAK it with CTRL-BREAK,
put DoEvents into the loop

DoEvents will also update values written to a form by a general
procedure or code behind another form or report

A DoEvents is done when you use MsgBox, or are stepping through code
(since it has to pay attention to the keyboard)

It is a good way to say, "Wake Up!"


Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top