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

  • Follow


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


0
Reply Utf 1/31/2008 8:24:01 PM

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

"Jonathan Brown" <JonathanBrown@discussions.microsoft.com> wrote in message 
news:96AB68F9-5A9D-4ACE-BD91-708C0C76042B@microsoft.com...
>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
>
> 


0
Reply Jeanette 1/31/2008 8:32:48 PM


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" wrote:

> 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
> 
> 
0
Reply Utf 1/31/2008 8:46:01 PM

I could not shower enough praise upon you both.  I envy your kung fu.

"Klatuu" wrote:

> 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" wrote:
> 
> > 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
> > 
> > 
0
Reply Utf 1/31/2008 9:01:01 PM

Thanks for the kind works, Jonathan.  To be clear, I have much more fu than 
kung :)
-- 
Dave Hargis, Microsoft Access MVP


"Jonathan Brown" wrote:

> I could not shower enough praise upon you both.  I envy your kung fu.
> 
> "Klatuu" wrote:
> 
> > 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" wrote:
> > 
> > > 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
> > > 
> > > 
0
Reply Utf 1/31/2008 9:07:03 PM

4 Replies
355 Views

(page loaded in 0.206 seconds)

Similiar Articles:















7/25/2012 12:12:48 PM


Reply: