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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Requery a combobox from another form.

Status
Not open for further replies.

Albion

IS-IT--Management
Aug 8, 2000
517
US
I have a form (frmQuoteFormEdit) on that form there is a combobox (cboCustomers) that has a list of our customers that it gets from an SQL Query in it’s Row Source:

SELECT tblCustomers.Abbreviation, tblCustomers.Customer_Name FROM tblCustomers ORDER BY tblCustomers.Customer_Name;

Next to that combobox I have a button for adding a new customer. When that button is clicked a new form (frmNewCustomer) with the Control Source of tblCustomers to a new Record is opened. After entering a new customer the user clicks on the OK button that closes frmNewCustomer and takes the user back to frmQuoteFormEdit. In the code for the OK button I have this:

Forms!frmQuoteFormEdit![cboCustomers].Requery

I've also tried

Forms!frmQuoteFormEdit.cboCustomers.Requery

I was hoping that the code would requery the combobox so that it contains the new customer but it doesn't. If I check the table it has actually been added. If I close frmQuoteFormEdit and open it again the new customer is there. I just can't figure out why the combobox isn't updating without closing the form. Any ideas?

-al
 
Hi!

Apparently you try to requery combobox until data isn't saved. Try to save new data before requery running.

docmd.RunCommand acCmdSaveRecord
Forms!frmQuoteFormEdit![cboCustomers].Requery


or put requery command string into Form_AfterUpdate or Form_UnLoad sub program.

private sub Form_AfterUpdate()
Forms!frmQuoteFormEdit![cboCustomers].Requery
end sub


or

private sub Form_UnLoad(cancel as integer)
Forms!frmQuoteFormEdit![cboCustomers].Requery
end sub


Aivars


 
That was my problem, thank you very much for the prompt response.

Craig
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top