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

search

Status
Not open for further replies.

e13c7r0nic

Programmer
Mar 12, 2006
1
US
Hello,

I want to create a form that has a text field, one command button, and a list field that displays the results of a query. The text field is where the input for the quiery would go and the search button would launch the search. The results should be displayed in the list box.

-----------------------------------------
| |
| |
| /--------------\ --------------- |
| |text field | | search | |
| |--------------| -------------- |
| |
| |
| -------------------------------- |
| | | |
| | | |
| | results | |
| | | |
| | | |
| |------------------------------| |
|--------------------------------------|


I've been stumbling around to make this work. So far, I've figured that I'll need to use a subform to display the results of the query. What I don't know is how to make the query take the text from the text box and use it as the argument and then display the results in the list box.

I want to disply the results in something that looks like datasheet view, but in the form. I've read that this can be done with a subform, using the header to disply the field names, and then using a list box to display the results in the deatails part of the subform.

The part I can't work out is the actual macro that runs the quiery passing the text in the text field as the argument and then piping the results into the list box.

Any help would be greately aprecciate it.

Thanks in advance.

adolfo
 
If you change the subform to datasheet, then the subfrom will display the way you want. Are you going to let the user select the field they want to use for testing the search string? Usually this kind of operation is done with vba code, putting the text into the subform's filter property. Are you willing to give this a try with some help from your friends?
 
like stix42 said, you probablty want to consider VBA.

Why do you need a list box in the subform? One or the other.
Listbox is easiest.

On cmdClick

Dim SQL As String

SQL = _
"SELECT txtName, txtCity FROM tblCompany " & _
"WHERE txtCity ='" & Me.txtSearch & "'"

Me.lstRecords.Rowsource = SQL

or, if you decide subform;

Me.sfrmRecords.Form.Recordsource = SQL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top