Update Combo Box

geno

Registered User.
Local time
Today, 14:31
Joined
Jun 19, 2000
Messages
243
I have a combo box that the user can use to find a customer. Then I have a command button on the form that brings up a form to add a new customer. After closing this form the combo box dosen't have the new customer. If I close the form and reopen it then the new customer is there. Is there a way to automatically update the combo box after adding the new customer?
 
Greetings Geno. Here's what you do. Code the data entry form's 'OnClose' event with the code below.
  • Forms![FirstForm].ComboName.Requery

Of course you'll need to replace 'FirstForm' with the name of the form containing the combo box and replace 'ComboName' with the name of the combo box. You may want to add some error handling in case the first form isn't open when you close the data entry form. But, that's it. Good luck.

~Abby
 
Thanks abby, that worked. But another problem has arose. The new customer is added to the combo box, but when I click on the new customer, the form is not updated with that record. The information is from another customer. If I exit then go back in the customer info is then updated. How do I update the form with the new customer information? Thanks I really appreciate your help.
 
I'm glad to help. To update the form you do basically the same thing you did for the combo box. Here:
  • Forms![FirstForm].Requery

This will update the form and all the controls on it. So, you don't need the old line of code and can replace it with this one. However, requerying the form will also take you back to the first record. If that's an issue for you, do a search on this site for a topic titled 'Refresh/Requery Form' posted by Rosebud. That will give you some code that may help. Best of luck to you.

~Abby
 

Users who are viewing this thread

Back
Top Bottom