Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Requery drop-down list 1

Status
Not open for further replies.

radioman000

Technical User
Dec 19, 2003
10
0
0
US
Hello all,

I have a customer service database that contains a service workorder form. This form has a combo box that uses a query to obtain a drop-down list of customer names. In the event that a customer name is not in the list, a button on the form will open my customer maintenance form and allow you to add a new customer. After adding a new customer, in order for the new customer name to show up in the drop-down list, you must close the new workorder form and reopen it. Is there a way to have the query run again upon closing the "add a new customer" form so the drop-down list will re-populate?

Thanks

Radioman000
 
In the event that OPENS the NewCustomer form you'll have a

DoCmd.OpenForm "frmNewCustomer", , , , , acDialog

It is important that you have the Window mode set to acDialog because this suspends the running of the code in the originating event until the frmNewCustomer is closed again.

So the line after the DoCmd.OpenForm can be a

cboListCustomers.Requery

which will requery the RowSource of the combo box for you.



As an alternative approach consider
Setting the combo box's LimitToList property to YES
Then putting code into the OnNotInList event

This way if the user enters details in the combo box that do not correspond to an existing customer the NotInList event can open your NewCustomer form an prepopulate the data that the user has entered directly onto the form.
The NotInList event is then able to Requery automatically as a standard responce.
( Full details in the Help file under NotInList event etc. )



'ope-that-'elps.

G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
Thanks very much! The code [DoCmd.OpenForm "frmNewCustomer", , , , , acDialog] worked great!

Thanks again for the help!

Radioman000
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top