Force a combo box to requery after a pop up form has closed

  • Thread starter Thread starter Jonathan Brown
  • Start date Start date
J

Jonathan Brown

I want to make a combo box requery after I've closed a pop up form.
Basically the combo box shows a list of sites. I've added a button that
opens a pop up window to allow the user to create a new site. Once the user
clicks "save and close" the pop up form saves the record and closes. The new
site doesn't appear in the combo box until after I close the form and reopen
it.

Is there some way I can code the pop up form on it's unload event or close
event to force the combo box on the other form to requery?

I tried typing the following in the pop up forms unload event but it didn't
work:

[forms]![subfrmSites]![cboSites].Requery
 
Jonathan,
you can put code in either the got focus or on enter event of the combo to
requery the combo.
If the combo has heaps of records and the requery makes it slow, you could
move the requery to be done from the popup form after a new site has been
added, instead of the got focus or on enter of the combo.
Another possibility is to hide the popup after the new site has been
created. Your main form then reads the new site value from the popup and
closes the popup. At this point you requery the combo (because you know a
new site has been added).

Jeanette Cunningham
 
To make it work correctly, you have to open the popup in dialog mode so the
code in the main form will stop until the popup closes. Then requery your
combo in the next line:


Docmd.OpenForm "MyFormName", , , , , acDialog
Me.MyComb.Requery
 
I could not shower enough praise upon you both. I envy your kung fu.

Klatuu said:
To make it work correctly, you have to open the popup in dialog mode so the
code in the main form will stop until the popup closes. Then requery your
combo in the next line:


Docmd.OpenForm "MyFormName", , , , , acDialog
Me.MyComb.Requery

--
Dave Hargis, Microsoft Access MVP


Jonathan Brown said:
I want to make a combo box requery after I've closed a pop up form.
Basically the combo box shows a list of sites. I've added a button that
opens a pop up window to allow the user to create a new site. Once the user
clicks "save and close" the pop up form saves the record and closes. The new
site doesn't appear in the combo box until after I close the form and reopen
it.

Is there some way I can code the pop up form on it's unload event or close
event to force the combo box on the other form to requery?

I tried typing the following in the pop up forms unload event but it didn't
work:

[forms]![subfrmSites]![cboSites].Requery
 
Thanks for the kind works, Jonathan. To be clear, I have much more fu than
kung :)
--
Dave Hargis, Microsoft Access MVP


Jonathan Brown said:
I could not shower enough praise upon you both. I envy your kung fu.

Klatuu said:
To make it work correctly, you have to open the popup in dialog mode so the
code in the main form will stop until the popup closes. Then requery your
combo in the next line:


Docmd.OpenForm "MyFormName", , , , , acDialog
Me.MyComb.Requery

--
Dave Hargis, Microsoft Access MVP


Jonathan Brown said:
I want to make a combo box requery after I've closed a pop up form.
Basically the combo box shows a list of sites. I've added a button that
opens a pop up window to allow the user to create a new site. Once the user
clicks "save and close" the pop up form saves the record and closes. The new
site doesn't appear in the combo box until after I close the form and reopen
it.

Is there some way I can code the pop up form on it's unload event or close
event to force the combo box on the other form to requery?

I tried typing the following in the pop up forms unload event but it didn't
work:

[forms]![subfrmSites]![cboSites].Requery
 
Back
Top