Dlookup using Yes/No field as criteria

FCrocco

New member
Local time
Today, 11:32
Joined
Sep 26, 2023
Messages
6
I'm not being able to find the correct sintax do use Yes/No field as a criteria in my Dlookup function:

AttachPrep = DLookup("[Flux]", "251 Preparation", "[Selected]= Yes")

Many other sintaxes like -1, true, etc...... all return data type mismatch .

Any help? Any clue?
 
What data type is AttachPrep variable? What field type is Flux?

DLookup() returns Null if no match found. All domain aggregate functions will, except DCount().

Why is DLookup needed? What are you trying to accomplish?
 
Last edited:
It's interesting to note that you used square brackets around the field's name but not around the name of the table that has a space in it. I wonder if that could cause problems as well.
 
No, DBguy, I have tested that. Domain aggregate will accept spaces and symbols in table/query name without brackets but not in field name.
 
No, DBguy, I have tested that. Domain aggregate will accept spaces and symbols in table/query name without brackets but not in field name.
That is very interesting. I wonder what "they" were thinking?
 
I wonder what "they" were thinking?

Beats me. I have a strong preference for consistency. I almost don't care what the decision is. I just want it to always be the same. There are situations where in the QBE if you type a column name, Access helps and surrounds it with quotes assuming it is a variable and other places where it assumes it is a column name and surrounds it with square brackets. On more than one occasion I have updated a column in all rows to "SomeFieldName". Good think I'm anal about creating backups before running untested bulk update queries.
 
I'm not being able to find the correct sintax do use Yes/No field as a criteria in my Dlookup function:

AttachPrep = DLookup("[Flux]", "251 Preparation", "[Selected]= Yes")

Many other sintaxes like -1, true, etc...... all return data type mismatch .

Any help? Any clue?
= DLookup("[Flux]", "251 Preparation", "[Selected]= True")
 

Users who are viewing this thread

Back
Top Bottom