Update combo box after table change

  • Thread starter Cliff Partridge
  • Start date
C

Cliff Partridge

I have a combo box in a form that I use to select a customer name from
a customer table. If the customer doesn't exist, I created a button
to open another form to enter their information. The problem is that
after I enter the new customer information, I can't see them in the
list on the combo box until I exit out of the orginal form and go back
in. How do I make the combo box update automatically without having
to exit and re-enter?

I tried to search on this, but didn't have much luck.

Cliff
 
P

PC Datasheet

Cliff,

Put the following code in the OnClick event of your button:

DoCmd.OpenForm "NameOfYourCustomerForm",,,,,acDialog
Me!NameOfYourComboBox.Requery
Me!NameOfYourComboBox.SetFocus
Me!NameOfYourComboBox.DropDown

You need a button on your customer form that closes the form after the new
customer is entered.


--
PC Datasheet
A Resource for Access, Excel and Word Applications
(e-mail address removed)
www.pcdatasheet.com

· Design and basic development for new applications
· Additions, Modifications and "Fixes" for existing applications
· Mentoring for do-it-yourselfers who want guidance
· Complete application design and development
· Applications Using Palm Pilot To Collect Data And
Synchronize The Data Back To Access Or Excel
 
C

Cliff Partridge

Unfortunatly, I don't completely follow the directions here (I'm a VBA
novice). Do I need to put a button on the form, that opens to enter
a new cutomer, that will exit back to the "main" form; and put the
code in the OnClick event in that new button? Or does the code go in
the bbutton that opens the Customer Form?

Either way there is already code in the OnClick event, which I assume
Access did automatically. So, does it matter where I put the new
lines of code in relation to the existing lines?

Cliff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top