AfterUpdate only triggered once

S

schwigg

This problem surfaced while working on a larger project, but to
simplify things...

Let's assume that I have two forms, aForm and aSubForm. aSubForm is
included as a subform on Form. Form includes a combo box named aCombo
that is populated based on the data controlled by aSubform. So, if I
go to select a value in aCombo but do not find it there, I can add an
additional record into aSubform with the idea that it will immediately
appear within aCombo as an available choice.

(Side note: I realize I could use NotInList for aCombo for this
example, but the real-world application of this is a bit more
complicated.)

I set the AfterUpdate event of aSubform to do the following event
procedure:


Private Sub Form_AfterUpdate()

Forms!aForm.Requery

End Sub


This works great for the *first* time that I update aSubForm: after
adding the record to aSubForm, the option appears within the aCombo
field. However, subsequent updates are recorded within aSubForm (and
the table behind it) but are not reflected in aCombo. These changes
*will* be reflected by closing and reopening aForm. Some testing with
message boxes in the AfterUpdate Sub above has shown that the
AfterUpdate event is only being triggered on the first update.

Am I doing something wrong? Or will the AfterUpdate event only trigger
once?

Thanks!
 
A

Allen Browne

You are requerying the main form instead of requerying the combo on the main
form. Try:
Me.Parent![aCombo].Requery

Presumably this combo is not part of LinkMasterFields. You could end up with
a circular dependency.
 

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