473,387 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Boolean criteria with DLookup

Hi

How do I use a boolean criterian with the funktion DLookup ?

I know the syntax for strings, numeric and date as follows

For numerical values:
DLookup("FieldName" , "TableName" , "Criteria = n")

For strings: (note the apostrophe before and after the value)
DLookup("FieldName" , "TableName" , "Criteria= 'string'")

For dates:
DLookup("FieldName" , "TableName" , "Criteria= #date#")

For booleans:
?????????????

best regards
Ronald

Apr 19 '06 #1
6 10676
No delimiters. Same as numbers, e.g.:
DLookup("FieldName" , "TableName" , "Criteria = False")

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<bj**@vestas.com> wrote in message
news:11**********************@e56g2000cwe.googlegr oups.com...
How do I use a boolean criterian with the funktion DLookup ?

I know the syntax for strings, numeric and date as follows

For numerical values:
DLookup("FieldName" , "TableName" , "Criteria = n")

For strings: (note the apostrophe before and after the value)
DLookup("FieldName" , "TableName" , "Criteria= 'string'")

For dates:
DLookup("FieldName" , "TableName" , "Criteria= #date#")

For booleans:
?????????????

best regards
Ronald

Apr 19 '06 #2
Hi Allen

And thank you
It is working fine with only the boolean criteria, but when I add other
criteries I can't get it working.

Look at this:

Dim VareVar As String
Dim SerialNoVar As String
Dim DatoAfslVar As Date

If Not IsNull(VareVar = DLookup("VareNr", "T_FejlRecords",
"[VareNr] = '" & VareVar & "'" _
& "And [SerieNr] = '" &
SerialNoVar & "'" _
& "And [DatoAfsl] = #" &
DatoAfslVar & "#" _
& "And Repair = TRUE")) Then

This statement don't take notice of the "And Repair = TRUE"

What am I doing wrong ?

best regards
Ronald

Apr 21 '06 #3
Br
bj**@vestas.com wrote:
Hi Allen

And thank you
It is working fine with only the boolean criteria, but when I add
other criteries I can't get it working.

Look at this:

Dim VareVar As String
Dim SerialNoVar As String
Dim DatoAfslVar As Date

If Not IsNull(VareVar = DLookup("VareNr", "T_FejlRecords",
"[VareNr] = '" & VareVar & "'" _
& "And [SerieNr] = '" &
SerialNoVar & "'" _
& "And [DatoAfsl] = #" &
DatoAfslVar & "#" _
& "And Repair = TRUE")) Then

This statement don't take notice of the "And Repair = TRUE"

What am I doing wrong ?

best regards
Ronald


I always assign the criteria to a string variable so I can easily msgbox or
debug.print it to make sure the format is correct before passing it on to
the next part of the procedure. I also tend to put brackets arount each
criteria to make it more readable.
--
regards,

Br@dley
Apr 21 '06 #4
Ted
Looks like on the "And Repair = TRUE" you strayed from the format you
were using on the other comparisons. Try: " And [Repair]=TRUE" or " And
[Repair]=" & -1
bj**@vestas.com wrote:
Hi Allen

And thank you
It is working fine with only the boolean criteria, but when I add other
criteries I can't get it working.

Look at this:

Dim VareVar As String
Dim SerialNoVar As String
Dim DatoAfslVar As Date

If Not IsNull(VareVar = DLookup("VareNr", "T_FejlRecords",
"[VareNr] = '" & VareVar & "'" _
& "And [SerieNr] = '" &
SerialNoVar & "'" _
& "And [DatoAfsl] = #" &
DatoAfslVar & "#" _
& "And Repair = TRUE")) Then

This statement don't take notice of the "And Repair = TRUE"

What am I doing wrong ?

best regards
Ronald


Apr 21 '06 #5
bj**@vestas.com wrote in
news:11**********************@u72g2000cwu.googlegr oups.com:
Hi Allen

And thank you
It is working fine with only the boolean criteria, but when I
add other criteries I can't get it working.

Look at this:

Dim VareVar As String
Dim SerialNoVar As String
Dim DatoAfslVar As Date

If Not IsNull(VareVar = DLookup("VareNr",
"T_FejlRecords",
"[VareNr] = '" & VareVar & "'" _
& "And [SerieNr] = '"
&
SerialNoVar & "'" _
& "And [DatoAfsl] =
#" &
DatoAfslVar & "#" _
& "And Repair =
TRUE")) Then

This statement don't take notice of the "And Repair = TRUE"

What am I doing wrong ?

best regards
Ronald


If you were to put the criteria into a variable and examine the
result in the immediate window, you would see that it returns

"[VareNr] = 'xxxxxxx'And [SerieNr] = 'yyy'And [DatoAfsl] =
#04-21-06#And Repair = TRUE"

You need to insert some spaces in front of your ANDs

You also need to verify that VareVar name You are trying to set
it and use it at the same time.

--
Bob Quintal

PA is y I've altered my email address.
Apr 21 '06 #6
Thank You all

It's working now

Ronald

Apr 24 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: KLAU | last post by:
I have a field that retrieves information from an expression in a query. I have used a DLookup function to get the calculated field from the query. However, the relationship is 1-to-many so one...
4
by: ShyGuy | last post by:
I have a table with 4 fields. Three are used for criteria. I can get the DLookup to work with 1 criteria with the following but can't get it to work with 2 or three. NumofAppts = DLookup("",...
7
by: Tony Williams | last post by:
Does DLookup work in an expression in a query? I have this expression -(DLookUp("","tblmaintabs","= ")) Which works fine as a calculated control on a form but when I try to use it in a query as an...
11
by: MLH | last post by:
DLookup("", "tblPreliminaryVINs", "=Forms!frmVINODO!SerialNum") is giving me a Type Mismatch error. That's confusing to me and I don't know how to circumvent it. The field in...
2
by: chris.thompson13 | last post by:
I am having a problem setting the criteria part of the DLookup method correctly and am consequently getting an error message. I have a database of staff duties, part of which is a query (qryDaily)...
3
MSeda
by: MSeda | last post by:
I have a loop that is controlled by a Dlookup statement with two criteria. Both criteria fields are checkboxes. I have tried an assortment of quotation marks in the criteria section and cannot get...
11
by: vkong85 | last post by:
I'm creating a database for work and i've run into a snag. Currently i'm using to nested dlookup statements and they are searching for certain criteria in order to find the correct value the...
2
by: Denise | last post by:
Front end is Access 2002, back end is linked Oracle tables. My users need to describe things in feet and inches and want to use the standard ' and " abbrevations. On a testing form I go to a...
1
by: Constantine AI | last post by:
Hi i am trying to get User input if data does not exist within a DLOOKUP table. I have gotten it to work for one record but not multiple, i have tried to incorporate my code into a loop procedure but...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.