How to refresh a COmbo Box

  • Thread starter Thread starter Jorge
  • Start date Start date
J

Jorge

Hi everybody,
I'm sorry for such a dumb question but I can't find out
how to do it.

I have a form (let's say Form A) with a CUSTOMERS Combo
Box, and a button to Add new customers that opens
Customers Form. When I add a new customer and close
Customers Form, I want the combo box in Form A to contain
the new row added.

I've tried with DoCmd.Requery in different events on both
forms with no success. I'm really a newbie with Access.
Thank you for your comments!
Regards,
Jorge


PS: The Combo Box is in a subform and the Add New
Customer button is in its parent form. Does it matter?
 
Try placing the following in the OnClose event of the
Customers Form:

FormA!Combo Box Name.Refresh

You'll need to modify the above statement to contain the
actual name of your form and the actual name of the combo
box. I might suggest that you would use the Build option
to create the statement.

Byron
 
You need to use a Requery command, but because the combo box is in the
subform, you need to use a full reference to the combo box if you're running
the requery in the Customers form. Something like this could be put in the
OnClose event of the Customers form:

Private Form_Close()
Forms("Form A").Controls("Subform Control
Name").Form.Controls("CUSTOMERS").Requery
End Sub

where Subform Control Name is the name of the subform control on the Form A
(the subform control is the control that holds the subform). I'm assuming
that your first form is named Form A and that the combo box is named
CUSTOMERS.
 
Thanks Byron,
It's not working yet but I'll keep trying. I used the
Build option to reference the form and I get an error
each time I close Customers Form (Object Required, or MS
Access can't find the form ... referenced in a macro).

I have the combo box inside a subform. Should I reference
FormA!SubformName!ComboBoxName.Refresh ? or
OriginalSubformName!ComboBoxName.Refresh?
Actualy I've tried both and it didn't work yet, but I'll
keep trying.
I'll keep building an event in OnClose at Customers Form.

THANK YOU!!!
Jorge
 
THANK YOU!!!
That really worked!!!

Thank you and Byron for your comments.
Have a great weekend!!
Jorge
 
Back
Top