Creating a search function

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

Guest

I have a table which is linked to an exel spreadsheet. The table is an
inventory of our computers which includes Customer # and Service Tags as
fields. I am trying to create a from which will have a Combo Box on it and a
Command Button. The user will type a service tag into the Combo Box and click
the Command Button which will then run a query and display the information
for that system.
 
Include a reference to the combo box as a parameter in a query, e.g.

SELECT *
FROM YourTable
WHERE [Service Tag] = Forms!YourForm!cboServiceTags;

where YourForm is the name of the form with the combo box and cboServiceTags
is the combo box's name. In the Click event procedure of the button on the
form you can open the query directly with the OpenQuery method but a better
approach would be to bind a form to the query and open the form:

DoCmd.OpenForm "YourBoundForm"

For the RowSource property of the combo box on the search form use a query
which returns distinct Service Tag values:

SELECT DISTINCT [Service Tag]
FROM YourTable
ORDER BY [Service Tag];
 
Thank you very much Ken.

Ken Sheridan said:
Include a reference to the combo box as a parameter in a query, e.g.

SELECT *
FROM YourTable
WHERE [Service Tag] = Forms!YourForm!cboServiceTags;

where YourForm is the name of the form with the combo box and cboServiceTags
is the combo box's name. In the Click event procedure of the button on the
form you can open the query directly with the OpenQuery method but a better
approach would be to bind a form to the query and open the form:

DoCmd.OpenForm "YourBoundForm"

For the RowSource property of the combo box on the search form use a query
which returns distinct Service Tag values:

SELECT DISTINCT [Service Tag]
FROM YourTable
ORDER BY [Service Tag];

John said:
I have a table which is linked to an exel spreadsheet. The table is an
inventory of our computers which includes Customer # and Service Tags as
fields. I am trying to create a from which will have a Combo Box on it and a
Command Button. The user will type a service tag into the Combo Box and click
the Command Button which will then run a query and display the information
for that system.
 
Back
Top