Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

How refresh/requery combobox on 1st form when 2nd form closes

I have a combobox on form 1 which the user uses to select a record to open form 2.  When form 2 closes via a command button I want the records in the combobox on form 1 to be requeried.

How can I do this?

--Steve
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Try:

Forms!Form1!YourCombobox.Requery
In the code of your Command Button in form 2 that closes the form, add:
Forms!NameOfForm1!NameOfCombobox.Requery

Edit... same as Jeff posted above.
Avatar of SteveL13

ASKER

I am so sorry... I forgot one thing.   There will be times when form 1 isn't open.  So the code has to check for that first.  

??
Here you go:
If CurrentProject.AllForms("NameOfForm1").IsLoaded = True Then
    Forms!NameOfForm1!NameOfCombobox.Requery
End If
Hmmm, that didn't work.  When I got back to form 1 the records in the combobox were not requeried.
ASKER CERTIFIED SOLUTION
Avatar of IrogSinta
IrogSinta
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Steve,

1. Ron's coding looks solid...
(silly question, did you substitute your actual object names in his code...?)
;-)

2. Make sure you code is actually "adding" this value to the underlying table...
For example, if you run Ron's code, ...immediately open the *Table* that stores this value, ...is the value added?

JeffCoachman