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

Same basic query used with different parameters 2

Status
Not open for further replies.

nastar1

Technical User
Nov 1, 2005
122
0
0
US
Is there a technique to using the same basic query only changing a parameter each time you run it?

Say for instance I am using a query that captures all records from a table with fields:

Name
Position
OfficeSymbol


I then want to be able to run the query to select based upon a parameter with the Name. Another query parameter with the Position and lastly another parameter using the OfficeSymbol.

Currently I have a separate query built for each of these requests, but thinking there is a more efficient use of the query that I am missing.

I also would like to apply the same idea to the multiple reports I have written that each run based upon one of the parameter queries I have built. Seems there must be a way to reduce the number of queries and reports that all collect and display the same basic fields only being limited to the parameter used.
 
It is possible to build an SQL string and use this for the record source. The record source can be changed programmatically, for example:

Me.RecordSource = "SELECT Name, Position, OfficeSymbol " _
& "FROM tblT WHERE Name Like '*" & Me.txtCriteria & "*'"

A query can also reference a form field:

You can use filters - these can be built 'on-the-fly'.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top