Dlookup using Yes/No field as criteria (1 Viewer)

FCrocco

New member
Local time
Today, 06:38
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?
 

June7

AWF VIP
Local time
Today, 01:38
Joined
Mar 9, 2014
Messages
5,472
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:

theDBguy

I’m here to help
Staff member
Local time
Today, 02:38
Joined
Oct 29, 2018
Messages
21,473
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.
 

June7

AWF VIP
Local time
Today, 01:38
Joined
Mar 9, 2014
Messages
5,472
No, DBguy, I have tested that. Domain aggregate will accept spaces and symbols in table/query name without brackets but not in field name.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:38
Joined
Oct 29, 2018
Messages
21,473
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?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 05:38
Joined
Feb 19, 2002
Messages
43,275
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.
 

LarryE

Active member
Local time
Today, 02:38
Joined
Aug 18, 2021
Messages
591
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

Top Bottom