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

How can I lookup a value that is between dates in another table

I have a table called 'RawData' that collects production data. We run a
report on this data everyday to see the performance of each employee. I
have another table called 'tblStandards' with standards for each area
and an effective date of the standard. Any production numbers before
the effectivity date will use the older standard and any on or after
the date will use the newer standard. My problem is how to write a
formula in a query that will pull the correct standard for each record.
In 'tblStandards' I have the following fields:

Type (Text) - Defines which department the standard is for.
Category (Text) - Area within department
Standard (Number, Long Integer)
EffectiveDate (Date/Time)

------------------------------------
Example: (there are other fields, I will only include the necessary
ones)

Data for two records in RawData are
Category Date
------------- ---------
Record #1: Consumer 5/5/06
Record #2: Consumer 8/2/06

Standards include the following records:

Type Category Standard Effective Date
------- ------------- ------------- -------------------
Spares Consumer 90 1/1/2006
Spares Small 30 1/1/2006
Spares Large 15 1/1/2006
Spares Consumer 80 6/1/2006
Spares Consumer 70 9/1/2006

Record #1 should return standard of 90
Record #2 should return standard of 80

I tried DMax and DLookup but neither work the way had hoped. Maybe I
don't have it written correctly.
Query fields are:

Field: EmployeeID
Table: RAW Data

Field: Date
Table: RAW Data

Field: Standard: DLookUp("[Standard]","tblStandards","[Category]
='Consumer' " And "[EffectiveDate] <=" & [Date])
Table:

I included 'tblStandards' in my query but of course there are no fields
to create a join. One of the problems I found with DLookup is that it
runs very slow.
Help! This is driving me crazy!

Jan 11 '07 #1
1 4106
See:
Lookup in a range of values in a query
at:
http://allenbrowne.com/ser-58.html

Tom Ellison explains how to query this efficiently. It is worth the effort
to follow through what he describes.

--
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.

"Beeker" <Sc********@bdhhi.comwrote in message
news:11**********************@i56g2000hsf.googlegr oups.com...
>I have a table called 'RawData' that collects production data. We run a
report on this data everyday to see the performance of each employee. I
have another table called 'tblStandards' with standards for each area
and an effective date of the standard. Any production numbers before
the effectivity date will use the older standard and any on or after
the date will use the newer standard. My problem is how to write a
formula in a query that will pull the correct standard for each record.
In 'tblStandards' I have the following fields:

Type (Text) - Defines which department the standard is for.
Category (Text) - Area within department
Standard (Number, Long Integer)
EffectiveDate (Date/Time)

------------------------------------
Example: (there are other fields, I will only include the necessary
ones)

Data for two records in RawData are
Category Date
------------- ---------
Record #1: Consumer 5/5/06
Record #2: Consumer 8/2/06

Standards include the following records:

Type Category Standard Effective Date
------- ------------- ------------- -------------------
Spares Consumer 90 1/1/2006
Spares Small 30 1/1/2006
Spares Large 15 1/1/2006
Spares Consumer 80 6/1/2006
Spares Consumer 70 9/1/2006

Record #1 should return standard of 90
Record #2 should return standard of 80

I tried DMax and DLookup but neither work the way had hoped. Maybe I
don't have it written correctly.
Query fields are:

Field: EmployeeID
Table: RAW Data

Field: Date
Table: RAW Data

Field: Standard: DLookUp("[Standard]","tblStandards","[Category]
='Consumer' " And "[EffectiveDate] <=" & [Date])
Table:

I included 'tblStandards' in my query but of course there are no fields
to create a join. One of the problems I found with DLookup is that it
runs very slow.

Help! This is driving me crazy!
Jan 11 '07 #2

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

Similar topics

1
by: fak | last post by:
I have a workorder entry form. There is a table that contains workorder information and another table that contains work dates that are closed (fully booked). When the workorder form is being...
9
by: Koen | last post by:
Hi all, My application uses a lot of lookup tables. I've splitted the frontend (forms, reports, etc) from the backend (data). The database has around 10 different users. The values in the...
7
by: Marco Simone | last post by:
Hi, What is your opinion about using Lookup field in table. I would like to use lookup field in table 1, so that I can choose data in combo box from table 2. Is this good design of database? ...
1
by: Zachary Turner | last post by:
I want to make a Lookup Field based on another Lookup field. In other words, I have this table A with two fields: ID and Name, where ID is an Autonumber and Name is a friendly name. Then I have a...
3
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems...
4
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box...
5
by: Rex | last post by:
Hi, I want to change a value in one table depending on the value(s) in another table. I am trying to achieve this in a form. to elaborate I have a many-to-many relationship between tables...
2
by: =?Utf-8?B?VEQgaXMgUFNQ?= | last post by:
I have a lookup table with and ID field and a Description field, and another table that has its own ID field, the ID field from the lookup table, and other data. LookupTable LookupTable.ID...
7
by: samdev | last post by:
I have set up a table with a few fields that are set to required....all work fine except the fields that are Lookup from another table. What am I forgetting to set? Thanks!!
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
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,...
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
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...

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.