Full Version: Name Combo box
UtterAccess Forums > Microsoft® Access > Access Forms
I have a form where I need to type in either the name or phone number to find the customer. I think I have the phone number working, but I am having trouble with the name. Would someone please look at and advise me. I would greatly appreciate. I am in a crunch.
Add an unbound combobox to your form and use the wizard. Choose option 3 and follow the prompts to get your combobox working.
For the name and phone number. I want to also be able to type a phone number to do a search and I have not been able to make that work.......
You want the same combobox to search in both fields? Post the code that is created by the wizard when you search just be one field and I can modify it for you to search in two fields.
I didn't see any comboboxes on your form. Last_Name and PhoneNumber are textboxes.
modified your form to use comboboxes.
BTW: The code:
Private Sub Form_Unload(Cancel As Integer)
Cancel = True
End Sub
Locks the form open.
Here is the updated DB
Thanks - that was Great!!! help....
The form is working fabulous except I added some code to open from another form and now the combo boxes will not update the form.
Hopefully this will explain:
Using the code below for two combo boxes worked great - but when I added the code to open from another form the code no longer works. The problem is with the OpenArgs I believe. I need a way to use the me.Filter for the combo boxes but I also need a way to open the form and show the Customer Name and phone number in the combo boxes and still be able to make selections from the combo boxes.
utton OnClick event to open form:
DoCmd.OpenForm "PaymentSummary", OpenArgs:=Me.CustomerID
Last_Name row source:
Row source SELECT Customers.CustomerID, [Last Name] & ", " & [First Name] AS Name FROM Customers;
PhoneNumber row source:
Row Source SELECT Customers.CustomerID, Customers.HomeNumber FROM Customers;
Private Sub Form_Open(Cancel As Integer)
Me![Last_Name] = Me.OpenArgs
'Detail.Visible = True
End Sub
Private Sub Last_Name_AfterUpdate()
Me.Filter = "CustomerID =" & Last_Name
Me.FilterOn = True
Detail.Visible = True
End Sub
Private Sub PhoneNumber_AfterUpdate()
Me.Filter = "CustomerID =" & PhoneNumber
Me.FilterOn = True
End Sub
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.