Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Declare a variable to be used in queries 1

Status
Not open for further replies.

ovs8

Technical User
Mar 15, 2004
63
US
Is there a way to declare a variable that could be used in multiple queries (including UNION queries), such as 'Start date' and/or 'End Date'. Do I have to bring all SQL statements into modules for that?

thanks,
oleg
 
You can have a global variable set in a module.

To reference it in the criteria of an equation, create a function of the appropriate type that returns the value.

for instance, put in a public module:

Code:
Public iMyVar as integer

Public Function GetiMyVar() as integer

GetiMyVar = iMyVar

End Function

of course, you can set that up with arguments if you needed to pass in query-specific information and return different mods of the initial value.


Alternately, you could have a table of INI type information, and do a DLookup on that table. Setup a table with an autonumber index, a text field called "Type" and a text field called "ArgValue1" (you can have several for more complex lookups).

You could put an entry in the table for

A#: (Autonumber)
Type: Sales
ArgValue1: 2

your Dlookup would be then:

=DLookup("ArgValue1","YourTableName","Type = Sales")

HTH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top