DLookUp and Parameterized Query

oravecz

New member
Local time
Today, 16:19
Joined
Jan 30, 2007
Messages
1
I am performing a DLookUp that uses a query (not a table) as the DOMAIN parameter.

Code:
DLookUp("[Some Column]", "Parameterized Query")

At the moment I don't care about any conditional clause. I would be happy getting the data for the first row.

Since I am using a parameterized query, when I run the query by clicking on it, it prompts me to type in the parameter. My dilemma is trying to figure out how to pass that parameter to the query using the DLookUp command.

Any ideas?
 
Instead of using a parameter in your query, consider using a function. If you define a public function that simply returns the value of a global variable, you can assign the function to the criteria of your query. Then, you simply "pass the parameter" by changing the value of the variable. A function similar to this would suit your purpose:
Code:
Public Function Get_Global() as String
    Get_Global = GBL_Parameter
End Function

Be sure that somewhere in the header of the module, you declare the GBL_Parameter variable as a Global variable:
Code:
Global GBL_Parameter as String

Now all that you do is put =Get_Global() into the criteria for your query where the parameter used to be, and in your code, you simply set the variable GBL_Paramter to the value you want for the query before you run your DLookup function. Hope this helped.
 

Users who are viewing this thread

Back
Top Bottom