473,411 Members | 1,894 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,411 software developers and data experts.

Dlookup with 2 criteria

MSeda
159 Expert 100+
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("[PPO Part#]", "Quoted Parts Table", "[PPO Quote Acc] = Yes And [PPO Order Parts] = Yes"))

I've never quite understood the logic of the quotation marks in the criteria statement but it usually works after several tries, this is the first time I,ve used Dlookup with 2 criteria. Any help will be appreciated
Oct 25 '06 #1
3 4490
NeoPa
32,556 Expert Mod 16PB
The amended code should work for you.

Expand|Select|Wrap|Line Numbers
  1. Do Until IsNull(DLookup( _
  2.    Expr:="[PPO Part#]", _
  3.    Domain:="Quoted Parts Table", _
  4.    Criteria:="(([PPO Quote Acc]) And ([PPO Order Parts]))"))
I've assumed from your code that [PPO Quote Acc] and [PPO Order Parts] fields are both of type Boolean so will not need to be compared to Yes.
If they are text fields and you need to compare against the text "Yes" then that is different and will need a code change.
Oct 25 '06 #2
MMcCarthy
14,534 Expert Mod 8TB
Two things:

Table and field names cannot contain blank spaces so they need to be inclosed in square brackets to show what they are.

Yes is text and all text has to be surrounded by single or double quotation marks (single inside a query).

therefore

Do Until IsNull(DLookup("[PPO Part#]", "[Quoted Parts Table]", "[PPO Quote Acc] = 'Yes' And [PPO Order Parts] = 'Yes'"))
Oct 26 '06 #3
NeoPa
32,556 Expert Mod 16PB
I missed out on the '[]' for the table name.

Expand|Select|Wrap|Line Numbers
  1. Do Until IsNull(DLookup( _
  2.    Expr:="[PPO Part#]", _
  3.    Domain:="[Quoted Parts Table]", _
  4.    Criteria:="(([PPO Quote Acc]) And ([PPO Order Parts]))"))
However, Yes can be a string but can also be an alternative for True - a predefined constant within VBA.
If you want Yes, the code above is ok, if you want "Yes" then change the last line to :-
Expand|Select|Wrap|Line Numbers
  1.    Criteria:="(([PPO Quote Acc] = 'Yes') And ([PPO Order Parts] = 'Yes'))"))
as shown by MMcCarthy above.
Oct 26 '06 #4

Sign in to post your reply or Sign up for a free account.

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...
8
by: Christine Henderson | last post by:
I have a problem using the above function in the following simplified circumstance: In the lookup table called "Klms Travelled" I have 3 fields, eg: Receiver Name Receiver Suburb ...
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)...
6
by: bjaj | last post by:
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" ,...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.