Using SQL in Access

timlowe

New member
Local time
Today, 03:23
Joined
Dec 4, 2003
Messages
8
Hi, im creating a query in Access using SQL. what i want is to have variables,

Like

WHERE e.date BETWEEN @from and @thru

It keeps telling me to declare the variable. can someone help me with the syntax on that please?

Thanks

Tim
 
The best way to do this is with parameter queries, which you should look up in the Help files. The reason is that parameter queries are pre-scanned so that Access already knows the best way to run them even without knowing the parameters.

There is also a way to build a string dynamically and execute it as SQL, but I'm going to recommend parameter queries as preferable.
 
only problem with that is I have this Huge SQL query i created, how can i incorportate the paramter queries into that?
 
A parameter query can be SQL-based. If you have the SQL, you can define the formal parameters in the SQL and then define the actual values when you activate the query.
 
would you be able to give me any hints on how to do this, i tried the help, but the directions didn't make any sense to me
 
I find that building queries in the query builder is the best way, you can add your parameters in the query builder, and then if you select the SQL view you can see the SQL generated by the query builder this way you will quickly develop an understanding of SQL.
 

Users who are viewing this thread

Back
Top Bottom