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

Need new record to show up in combo box

Status
Not open for further replies.

upplepop

IS-IT--Management
Jun 1, 2002
173
US
On an order form, I have a combo box that lists all the customers in my database. Next to it, I have a "Add New Customer" button that pops up another form where they can enter customer details. When they close that form, the new customer is not listed in the combo box.
I have found a way around it by asking if it is a new customer before the Order form is loaded, but I would like to be able to use the "Add New" button. Is there a way to "refresh" the combo box after adding a customer without reopening the form?
 
Once you're sure the new entry has been saved in the table that provides the Row Source for the combo box control (which may require an explicit Save or Update command in your program), issuing MyCombo.Requery should make it show the new record in its properly sorted place.

 
Just another thought -- If you have all the contact info fields on the form, you could add code something like this behind the NotInList event of your combo box. That way you wouldn't have to open a separate form to add the new customer info. This code is from my Work Order form which lets the user add a new customer/contact right on the form. It also immediately updates the combo box with the new customer/contact:

Private Sub ContactID_NotInList(NewData As String, Response As Integer)
On Error GoTo HandleErr

If MsgBox("Would you like to add this contact to the database?", _
vbYesNo + vbQuestion, "Contact not in JSJ database") = vbYes Then
Response = AddToList("Contacts", "ContactName", NewData)
Else
Response = acDataErrDisplay
End If


ExitHere:
Exit Sub

HandleErr:
Select Case Err
Case Else
MsgBox Err & ": " & Err.Description, , _
"Form_frmWorkOrder.ContactID_NotInList"
End Select
Resume ExitHere
Resume

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top