Criteria=Global Vairable

benc

Registered User.
Local time
Today, 18:13
Joined
Dec 31, 2001
Messages
57
How can i set the criteria to of a query to be the value of a global variable i have created. THanks
 
Use a function to return the value of the variable, you cannot directly reference it.

Function fnGetMyVariable() as String 'assume its a string
fnGetMyVariable = gVariable
End function.

Call the function as the criteria
 
Continuing the example posted by Fornatian,

Select *
From YourTable Where SomeField = fnGetMyVariable();
 
HOw can i insert the function a query, i can see any command to be able to do that.
 
Im sorry and i dont want to waste your time or sound stupid but i went into the design view of the query and could not see 'code builder'. I have a report that picks up the data from that query and therefore need to put the function in the query. Unless someone can think of a better idea for it. THanks
 
Switch to SQL View of the query and type the function in the Where clause as Pat has shown.
 
..or right click in the criteria row and select 'build', then in the expression builder choose functions-'name of your db' and the your functions will be listed on the right -double click to insert into the function fnGetMyVariable into the text box and OK. Your function doesn't require any arguments so job's a good 'un as we say up north.
 

Users who are viewing this thread

Back
Top Bottom