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

Parameter Query 2

Status
Not open for further replies.

lars7

Technical User
Aug 16, 2005
817
GB
Hi,
I need to send a query to excel but I need it to have multiple criteria in the same field like:

Code.
pmhnm04
n515
s34

I am sending groups of staff to payroll grouping them by a code. A parameter box will only allow me to put one code in at a time but I want them all to be in the same excel sheet and them to be emailed.



 
You could create a small temporary table of specific Code values. Join this table to your existing query to limit the results.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Hi Duane,
That sounds great do you know how I could do that ,I don't know that much about vba.

Tom.
 
There is no code needed. Just create a table with a single field to enter code values. Create a form bound to the table and add the field as a text box or combo box. You can then add records table.

The table is used in your query with an INNER JOIN to the code field. When the query is run, it will only include records where the code value is in your temporary table.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Hi Duane,
Thanks I would never have thought of that. Simple but very effective. To finish it off I would like to delete the contents of "tbltemp" rather than the whole table so that it's ready for the next batch of codes. Is there an easy way there too.

Tom.
 
You can do this manually by selecting all the records and pressing the delete key or use code like:
Code:
Dim strSQL as String
strSQL = "DELETE * FROM tblYourTempTable"
CurrentDb.Execute strSQL, dbFailOnError

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
The code worked great Duane thanks as always for your help.

Tom.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top