Using variables in sql view of a query

G

Guest

Hello,
I am building a query in access 2000, using sql view. In the process
I have realized that the sql statements here are much different then in a sql
server environment.
How can I use variables for e.g SQL SERVER CODE: DECLARE @weeknum INTEGER ??
How to use conditional statements like "if then else"
when I do both of these i get an error saying only "select", "insert" etc
are permitted. I cannot use it as a parameter to the query either,because I
need to compute it in the query.

Thanks,
MC
 
V

Van T. Dinh

***Untested****
PARAMETERS Param1 Long, Param2 Text;
SELECT Iif(T.NumField = Param1, {ValForTrue}, {ValForFalse}) AS Calc1
FROM YourTable AS T
WHERE T.TextField = Param2;
 
P

PC Datasheet

Look at QueryDef in the Help file - it sounds like this is what you are
looking for.
 
G

Guest

Thanks for your answers, I did look at the query def, but access help does
not really explain as to how you can convert plain query statements into
design view, I am new to using the design view.
I did find my way though with this problem.
Another problem I am running into is looping in a query. I want to do
something like this..
DO While date < '12/31/2004'
* do soemthing*
LOOP

Thanks- MC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top