473,398 Members | 2,165 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,398 software developers and data experts.

Multiple criteria in DLookup in Access.

2
I have a table called tblBoxRsum with fields LeagueID,BoxID,LowerRsum and UpperRsum.
In a query I have the fields EntryID,LeagueID and Rank
I want a Dlookup to find which BoxID the entry is in dependant on the LeagueID & Rank. All fields are numeric.
I have the following
Expand|Select|Wrap|Line Numbers
  1. BoxID: Nz(DLookUp("BoxID","tblBoxRsum","LeagueID="&[LeagueID] And "" & [Rank] & " Between LowerRSum And UpperRSum"),"")
This does not work. If I omit the LeagueID criteria it allocates correctly according to rank but obviously takes no notice of league duplicating boxIDs for entries.
Any help appreciated. Many thanks
Nov 30 '13 #1

✓ answered by zmbd

@OP:
Let's take a look at your where clause:
"LeagueID= "&[LeagueID] And "" & [Rank] & " Between LowerRSum And UpperRSum"
yuck

"(LeagueID= " & [LeagueID] & ") And (" & [Rank] & " Between " & LowerRSum & " And " & UpperRSum & ")"
if LowerRSum/UpperRsum are fields then enclose in square brackets; however, you note that the "BETWEEN" works so you may very well leave it alone other that the grouping.

THE SPACEING IS VERY IMPORTAINT too... the string is passed to the JET/ACE engine as a SQL "WHERE" clause; thus, if it wouldn't work in a query, it will NOT work in the DLOOKUP() either... you can [F1] for more information or do a net search for the command's details.

if [LeagueID] is text then add a single quote:
( = '" & [LeagueID] & "' AND " ) same with [Rank].

Also note the grouping with the "()" around the first and second conditions, this helps the DBEngine tell what is where and when.

@dgunner71:
In any event, I assume that LeagueID is a string
we try hard not to assume anything about the poster's intent. You will find very quickly that it is usually much better to ask a clarifying question than to attempt an answer that is potentially mis-leading.

In fact, if you find the question doesn't have enough information to attempt an outright answer you'll find that one of the Mods or Experts will be along shortly to ask for further details... or if lacking too much, the Mods (like myself) will simply pull the thread with some B-T-S comments to OP to help write a better a question.

4 3324
dgunner71
110 100+
snowy1,

I'm not sure how you're using this - a few of the 'Ands' appear to be out of place.

In any event, I assume that LeagueID is a string - as such, you'll need to enclose it in single parentheses. Also, you may want to break this up if it is separate criteria or create a concatenated field for part or all of the field.

Last, you may need to use Right() and Left() operators if some of your search will be on various parts of the same field.

Please tell me if League ID contains all the information you want to search by.

Gunner
Nov 30 '13 #2
zmbd
5,501 Expert Mod 4TB
@OP:
Let's take a look at your where clause:
"LeagueID= "&[LeagueID] And "" & [Rank] & " Between LowerRSum And UpperRSum"
yuck

"(LeagueID= " & [LeagueID] & ") And (" & [Rank] & " Between " & LowerRSum & " And " & UpperRSum & ")"
if LowerRSum/UpperRsum are fields then enclose in square brackets; however, you note that the "BETWEEN" works so you may very well leave it alone other that the grouping.

THE SPACEING IS VERY IMPORTAINT too... the string is passed to the JET/ACE engine as a SQL "WHERE" clause; thus, if it wouldn't work in a query, it will NOT work in the DLOOKUP() either... you can [F1] for more information or do a net search for the command's details.

if [LeagueID] is text then add a single quote:
( = '" & [LeagueID] & "' AND " ) same with [Rank].

Also note the grouping with the "()" around the first and second conditions, this helps the DBEngine tell what is where and when.

@dgunner71:
In any event, I assume that LeagueID is a string
we try hard not to assume anything about the poster's intent. You will find very quickly that it is usually much better to ask a clarifying question than to attempt an answer that is potentially mis-leading.

In fact, if you find the question doesn't have enough information to attempt an outright answer you'll find that one of the Mods or Experts will be along shortly to ask for further details... or if lacking too much, the Mods (like myself) will simply pull the thread with some B-T-S comments to OP to help write a better a question.
Nov 30 '13 #3
dgunner71
110 100+
Understood, zmbd.

Thanks for the direction.

Gunner
Dec 1 '13 #4
snowy1
2
Thank you. Worked perfectly once I sorted tblBoxRsum which did not have values for all BoxID.
Many thanks
Dec 1 '13 #5

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

Similar topics

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("",...
3
by: developing | last post by:
Hello How do I specify multiple criteria for FindFirst or FindRecord (or anything else) that takes the criteria from a form. (text field and number field) edit: this will be in the after...
4
by: JHNielson | last post by:
I have a query that I'm trying to update with a dlookup with multiple criteria This is the string: EVNT_DT: DLookUp("","","( .EVNT_QTR=.) & (.=.)") When i run it it says it can't find the...
3
by: kstevens | last post by:
Please help. I know the sysntax is wrong. Here are some details. I am looking for the sum of past shipped items. I originally wrote this Dsum with only one criteria, but because of multiple...
2
by: trinismooth | last post by:
Hi All Trying to do a dcount with multiple criteria for example: =DCount("","access rights"," = 'kev'" and ='Christian Fellowship members temp'" And ='yes'") Thanks for any assistance
1
by: Brendan Wolf | last post by:
Happy Halloween all, I have been struggling at work with a DLookup using multiple criteria. I would like a text box to display the results of a DLookup based on the values selected in three...
3
by: Brendan Wolf | last post by:
Happy Halloween all, I have been struggling at work with a DLookup using multiple criteria. I would like a text box to display the results of a DLookup based on the values selected in three...
4
by: W Sauce | last post by:
I am having trouble with creating an IIF Statement with multiple criteria. Ultimately I want it to do the following: IIF amount<0, 1 IIF amount>=0 and amount <100, 2 IIF amount >=100 and...
4
by: DANNYOCEAN | last post by:
I have a code that sucessfully calculates how many numbers are lower than for example 45 , for large sample number list. But i´m looking for a code that have a COUNT function with MULTIPLE...
14
by: Rinis | last post by:
I'm working on a timeclock system in a vba access database. I'm trying to get the system setup so when you hit the clock in button it checks to see if you have clocked in at some point that day. if...
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
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...
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
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
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,...

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.