Search a database by inputting data into a field on a form?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I search a table e.g. customer names by inputting the name into a
text box field on a form, I have set up the form and have a button to run the
event procedure, but what code do i need to write to search what has been
entered in the "Surname" field against surnames held in a table, and can i
display the results on another form in other text boxes?
 
Try this
Create a query with reference to the field in the form

Selec * From TableName Where FieldName = Forms![FormName]![FieldName]

If you want to display all the records that any part of them equal to the
value entered to the text box

Select * From TableName Where FieldName Like "*" &
Forms![FormName]![FieldName] & "*"

You can base a form on this SQL
 
Hi Ofer - I have done similar but it doesn't open/display the output in form.
It rather opens the output in query mode. What can I do so the form is
populated. Thanks for your help.

Ofer said:
Try this
Create a query with reference to the field in the form

Selec * From TableName Where FieldName = Forms![FormName]![FieldName]

If you want to display all the records that any part of them equal to the
value entered to the text box

Select * From TableName Where FieldName Like "*" &
Forms![FormName]![FieldName] & "*"

You can base a form on this SQL
--
I hope that helped
Good luck


Ambu-Al said:
How can I search a table e.g. customer names by inputting the name into a
text box field on a form, I have set up the form and have a button to run the
event procedure, but what code do i need to write to search what has been
entered in the "Surname" field against surnames held in a table, and can i
display the results on another form in other text boxes?
 
Back
Top