Discussion Locked

Passing an parameter to a Query in access

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a query in MS-Access which when run prompts for a parameter and then copies data from TableA to A Temp Table.
As I need the Query to run more than once how do I pass a parameter once or how do I do this using code?

Thanks

Brian

1 reply

by radobson

There are a couple of methods.

1. Build the SQL of the query with the parameter(s) in the text, then execute that. [ "Select * From TableName Where Field1 = '" & strField1Parameter & "'"]

2. Use ADO to and the Parameters collection.

Depending on the situation I'll use either. 1 is good for an Access only environment. 2. Is probably better for an MSDE or SQL Server environment.

The MSDN site at http://msdn.microsoft.com can provide a complete reference for ADO.

This discussion is closed to new replies.