Search Box in form

Roland87

Registered User.
Local time
Today, 02:28
Joined
Sep 5, 2012
Messages
26
Hi,

I have a form with a combo box I use to lookup records in one table, and I also have a list box with all of the records from another table.

Whenever I type in the combo box the name of a client the corresponding record and its fields appear, but the list box is unchanged, and does not select the client's name.

How can I get rid of the combo box, and have a simple search box which updates both the fields, and the list box?

I don't know any VBA so please explain. Thanks.
 
How are you getting the data with the combo?
Are you typing a name and other text boxes on the form are populating?

You could set you listbox to have a control source of a query that uses a search box as a parameter

i.e. SELECT * FROM tblTABLENAME WHERE fieldName LIKE * Forms!FormName!frmControl *

Add a textbox on the form, make sure it is matches "frmControl" name above.
Then run a listbox.Requery() in the AfterUpdate of the above textbox and or put it in a button event so you can press that instead.

Alex
 
I am not sure what you mean, I want one search box to populate other text boxes and to filter the list box at the same time. I tried putting that in a query, it says the syntax is wrong.
 
What does your query look like and what is the name of your search textbox?
 
regular query,

I put this in criteria:

SELECT * FROM Client Information WHERE Client Name LIKE * Forms!Form com!box1 *
 
Its best practice to not have spaces in your table names, field names etc
Try adding [ ] around those names.

Is that in the SQL view or did you add all of that in the query builder in the criteria row?
You would need to add the * as one column then add the client name as another column, untick it and add the Like... In the criteria
 
Last edited:
SELECT * FROM [Client Information] WHERE [Client Name] LIKE * Forms![Form com]!box1 *

it still gives me a message about syntax :(
 
Did you create the Query with the Query Builder?
(I updated a previous post)
 
I put it all in the criteria row, It's just for one field, do I need SQL here ?
 
You need to build the query up like I suggested in the Query Builder or change the view to SQL and paste in that full statement.
 
Okay, I think it works now. I've entered listbox.Requery() on the click of a button, and I've replaced listbox with its name, but it says it can't find the object, strange... Any ideas ? Should I put an equal sign or sthg?
 
John your tutorial is great, but I keep getting a message on the query and the form asking me to supply the parameter value for the text box SrchText. When I hit cancel, I get a run-time error 3021 in the visual basic window. Can you help me out? thanks.
 
Has the name of the Search textbox been changed to match the name you are using in the Query?
When Access pops up asking for a parameter it's because it can't find the one you are passing it, usually due to the spelling.
 
Has the name of the Search textbox been changed to match the name you are using in the Query?
When Access pops up asking for a parameter it's because it can't find the one you are passing it, usually due to the spelling.

Yes, of course, I followed the steps carefully. It has to be something else.
 
I finally got it to work, I don't know what went wrong, but when I changed the form's name it worked like a charm. Thank you very much Alex.
 
Glad you got it working :)

thanks to AlexHedley for assisting in my abscess :o
 

Users who are viewing this thread

Back
Top Bottom