473,657 Members | 2,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("FieldN ame" , "TableName" , "Criteria = n")

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

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

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

best regards
Ronald

Apr 19 '06 #1
6 10720
No delimiters. Same as numbers, e.g.:
DLookup("FieldN ame" , "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.co m> wrote in message
news:11******** **************@ e56g2000cwe.goo glegroups.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("FieldN ame" , "TableName" , "Criteria = n")

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

For dates:
DLookup("FieldN ame" , "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.goo glegroups.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
20776
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 site could have many units. How do I have the DLookUp field value change to a newly calcuated field when I navigate through the units? please see example below: On the Form: A site can have many units.
4
21085
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("", "LookUpAppts", " = " & Forms!!NumofPeople) Can someone tell me how to add multiple criteria? I tried "And" but it doesn't seem to work.
7
2253
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 expression I don't get any result. I want to use the Sum of the result in a query on which I will base a report. TIA Tony
11
2216
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 tblPreliminaryVINs is a 17-char text field. Forms!frmVINODO!SerialNum is just an unbound textbox on a form (frmVINODO). I run the DLookup during the textbox's BeforeUpdate event code. Some VIN values I type in there do NOT give rise to the error. Some do. By
2
2335
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) that returns all staffs duties for a selected day.e.g. Fullname Duty Name1 E1 Name2 Sick Name3 Pwk N2
3
4524
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 the Dlookup to run. My statement looks like this (I have removed the extraneous quotes since they are not working anyway): Do Until IsNull(DLookup("", "Quoted Parts Table", " = Yes And = Yes")) I've never quite understood the logic of the...
11
5480
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 statement reads: = DLookup ( "!" ," tbl Cost Center", "!= DLookUp("!","tbl people","!= Forms!!")") i've swapped the quotations marks and have tried god knows how many syntaxs for numeric and text. The first dlookup criteria is text. the second dlookup...
2
3642
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 record with double or single quotes in the location description and click a button to see if Access can tell me the ID number and find its way back to the original record. When the text contains double quotes the FindFirst works but the Dloookup...
1
3639
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 i have failed. Could anyone give me any advice? Dim db As Database Dim rst As Recordset Dim rst2 As Recordset Dim strSQL As String Dim Widthval As Integer Dim Depthval As Integer Dim Heightval As Integer Dim...
0
8392
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8305
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7324
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1953
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1611
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.