Use of variables in a query?

A

ACE Connection

Hi.
Is it possible to use variables in a query?
I need to make a test where I have to store info temporarily to make the
calculation, and hope to be able to make the SQL statements something like:

IIf([FIGB1]>[FIG1B2],$ST=[FIG1B1] And $SV=[FIG1B1],$ST=[FIG1B2] And
$SV=[FIG1B2])

where FIGB1 and FIGB2 are fields in a table, and ST and SV are the temporary
variables.

I have made this as a control in a form, and it works fine, but I have
problems to put the same logic into a query or report.

Thanks,
-Espen
 
D

Douglas J. Steele

The $ in front of the variable name makes me suspect you're not programming
using VBA in Access, so I'm not sure how useful what I have to say is going
to be.

You cannot simply put variables into a query.

If you strictly working within Access, you can create functions that return
the values of the variables, and use those functions in your queries.

If you're trying to read data from a Jet database, but from outside of
Access, I can't think of any alternatives.
 

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