Hello, I am trying to dynamically build a Dlookup function.
The way I am trying to do this is by using a variable named strNull:
strNull = "IsNull(DLookup(""lunes"", """ & strConsulta & """))"
Being "lunes" the name of the field I'm looking for and strConsulta the name of the query where I want to look up. This query name is what I need to be dynamically generated.
After that I evaluate strNull like this: If strNull = True Then...
Well, when I run this I get the error 13 "Type Mismatch". I guess it has to do with the syntax I'm using to build the strNull variable but I can't manage to find the right way to do it.
Any suggestions?
Thanks!
Dlookup built dynamically
-
- Administrator
- Posts: 78478
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Dlookup built dynamically
strNull is a text string, not an expression, even though it contains the text of an expression. To evaluate the expression, use the Eval function:
If Eval(strNull) = True Then
If Eval(strNull) = True Then
Best wishes,
Hans
Hans
-
- StarLounger
- Posts: 76
- Joined: 04 Jan 2013, 12:07
Re: Dlookup built dynamically
I didn't know about this "Eval" function
Thanks!
Thanks!
-
- Administrator
- Posts: 78478
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Dlookup built dynamically
It can be handy sometimes. See Application.Eval Method (Access).
Best wishes,
Hans
Hans