Macro doesn't work first time form is opened.


E

esn

Hi everyone,

I'm afraid this may be a corruption issue but let me know what you
think. I have a data entry form where users select a parent record
from a combo box then enter data into a subform. The subform is
disabled until the OnChange event of the combo box fires. Next to the
combo box is a button which opens a pop-up form for adding a new
parent record. On the pop up, the "Done" button sets the value of the
combo box to the ID of the newly added parent record, closes the pop
up, and enables the subform.

When the database is first opened and the user navigates to this data
entry form, this macro (OnClick for the "Done" button) doesn't work.
The new parent record is saved and the subform is enabled, but the
combo box remains blank and the new record doesn't appear as an
available value in the drop down list. SetValue actions can be weird
sometimes so I figured I screwed up somewhere or this was just the
wrong way of doing things. But then I realized that if I close the
data entry form and open it again, everything works like a charm.
When a new parent record is added and the "Done" button on the pop up
form is clicked, the combo box is set to the new record before the pop
up closes.

What the?
 
Ad

Advertisements

E

esn

A little more info -

I have another form that's basically a copy of the first, and it has
exactly the same issue. It's based on different tables, but they have
the same overall organization so the structure of the forms involved
is essentially identical. Behavior is exactly the same as described
in the first post - the setvalue action doesn't do anything unless the
form is closed and reopened.

Also, I checked OnClose and OnUnload events for all the forms
involved, and there's nothing there that should be causing a problem.
I figured this was the first place to look. The only things I have
for those events are a macro that runs an update query (specific to
one of the form copies, so it can't be the problem) and some restoring
minimized forms and closing related forms actions. I checked the
OnClose for the related forms as well and there's nothing.
 
Ad

Advertisements

E

esn

Never mind and thanks for looking - inserting a save record command
before the setvalue action fixed the strange behavior. I still don't
understand why the form would behave differently after closing and
reopening, but it's fixed.
 

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