Use of global variables in Queries

G

Guest

Is there a way to set global variables in an Access database and use those
variables in queries, without having thoes variables reside in a table or
query being used ...

Example.. i have a rate that is used multiple times in the same query, and
other queries.. i don't want to use a prompts, and for accuracy, it would be
ideal to have this a constant i could control with one update...

thanks

Paul
 
A

Amy Blankenship

Sounds like you could use a single-row constants table, and define
relationships to the tables where the constants will be used.

HTH;

Amy
 
G

Guest

i thought of that.. but then i'd need to join to that table to get the
constant.. which means i'd have to modify the tables and queries to join to
that table.. something that's not worth the effort at this time

Thanks
 
G

Guest

You can refer to a global variable in a query, by creating a function in a
module that return tha variable

Function FunctionName()
FunctionName = VariableName
End Function

In the query you can refer to the function
Select * From MyTable Where FieldName = FunctionName()
 
A

Amy Blankenship

Depends...for instance, if you have to access your query from outside Access
(asp, for instance), this won't work.

-Amy
 
A

Amy Blankenship

You'd have to modify the queries anyway, if you created a variable. You
should not have to modify any tables.

-Amy
 

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