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

DLookup/DMax?

We have vending machines which are serviced by emptying the money
inside the machine and placing it into numbered bags. Each bag is
numbered independently of the machines. Each machine has a sales
meter which tells me how much money should be in each bag.

I have two tables:

tblSales, which contains fields [MachineID], [CollectDate], [Bag] and
[Meter]

tblCounts, which contains fields [CountDate], [Bag] and [Amount]

The bags are counted, at the earliest, on the date they were
collected. In other words, tblCounts.[CountDate] >=
tblSales.[CollectDate]

Is there a way I can match up tblCounts.[Amount] to tblSales.[Meter]
using DLookup? My problem lies in the fact that there are multiple
matches in tblCounts.[Bag] for tblSales.[Bag]. These are the
criteria:

tblCounts.[Bag] = tblSales.[Bag]
tblCounts.[CountDate] >= tblSales.[CollectDate]

and finally, where I'm having problems, is that I need the record that
contains the maximum of tblSales.[CollectDate] AND meets the above
criteria. I have been trying various combinations of DLookup and
DMax, to no avail.

Obviously I am a shadetree Access user with no programming skills. I
am hoping that this can be accomplished via a query expression.

Thanks,
Rich
Nov 12 '05 #1
3 4564
I think you should perhaps look at it a different way
1 Table Machines containing MachineID, Meter and DateEmptied
1 Table Bags containing BagID (perhaps this could be a permanent number
written on the bag
MachineID (This would change depending on which machine had been
emptied)
DateCounted and Amount
The query joining the 2 tables will show the Meter and the Amount
You would have to devise methods of setting the DateCounted and Amount to
zero
Presumably the DateEmptied wiuld be assigned as the MachineID FK was entered
into the bag table

Phil
"Rich Bernat" <rb*****@autofrost.net> wrote in message
news:9c**************************@posting.google.c om...
We have vending machines which are serviced by emptying the money
inside the machine and placing it into numbered bags. Each bag is
numbered independently of the machines. Each machine has a sales
meter which tells me how much money should be in each bag.

I have two tables:

tblSales, which contains fields [MachineID], [CollectDate], [Bag] and
[Meter]

tblCounts, which contains fields [CountDate], [Bag] and [Amount]

The bags are counted, at the earliest, on the date they were
collected. In other words, tblCounts.[CountDate] >=
tblSales.[CollectDate]

Is there a way I can match up tblCounts.[Amount] to tblSales.[Meter]
using DLookup? My problem lies in the fact that there are multiple
matches in tblCounts.[Bag] for tblSales.[Bag]. These are the
criteria:

tblCounts.[Bag] = tblSales.[Bag]
tblCounts.[CountDate] >= tblSales.[CollectDate]

and finally, where I'm having problems, is that I need the record that
contains the maximum of tblSales.[CollectDate] AND meets the above
criteria. I have been trying various combinations of DLookup and
DMax, to no avail.

Obviously I am a shadetree Access user with no programming skills. I
am hoping that this can be accomplished via a query expression.

Thanks,
Rich

Nov 12 '05 #2
Thanks for your reply. Sorry for not specifying this, but each bag
does have a permanent number written on it.

Ideally, I would like to have MachineID included in tblCounts, but
that is just not feasible. What bothers me is that I have enough
information to match the bag to the machine based on the criteria but
am just unable to accomplish it yet. I still think it is possible
with an expression using DLookup and/or DMax.
"Phil Stanton" <di********@stantonfamily.co.uk> wrote in message news:<3f*********************@mercury.nildram.net> ...
I think you should perhaps look at it a different way
1 Table Machines containing MachineID, Meter and DateEmptied
1 Table Bags containing BagID (perhaps this could be a permanent number
written on the bag
MachineID (This would change depending on which machine had been
emptied)
DateCounted and Amount
The query joining the 2 tables will show the Meter and the Amount
You would have to devise methods of setting the DateCounted and Amount to
zero
Presumably the DateEmptied wiuld be assigned as the MachineID FK was entered
into the bag table

Phil

Nov 12 '05 #3
Whilest the MacchineID is not directly held in the tblCounts, it is visible
when the MachineID is linked to the Bag.

In the end I guess to want to end up with a table that is

MachineID Meter DateEmptied DateCounted Amount

I supect that for your audit purposes the Bag is irrelevant and only used as
a method of updating the above table

Phil
"Rich Bernat" <rb*****@autofrost.net> wrote in message
news:9c**************************@posting.google.c om...
Thanks for your reply. Sorry for not specifying this, but each bag
does have a permanent number written on it.

Ideally, I would like to have MachineID included in tblCounts, but
that is just not feasible. What bothers me is that I have enough
information to match the bag to the machine based on the criteria but
am just unable to accomplish it yet. I still think it is possible
with an expression using DLookup and/or DMax.
"Phil Stanton" <di********@stantonfamily.co.uk> wrote in message

news:<3f*********************@mercury.nildram.net> ...
I think you should perhaps look at it a different way
1 Table Machines containing MachineID, Meter and DateEmptied
1 Table Bags containing BagID (perhaps this could be a permanent number
written on the bag
MachineID (This would change depending on which machine had been emptied)
DateCounted and Amount
The query joining the 2 tables will show the Meter and the Amount
You would have to devise methods of setting the DateCounted and Amount to zero
Presumably the DateEmptied wiuld be assigned as the MachineID FK was entered into the bag table

Phil

Nov 12 '05 #4

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: lukeargent | last post by:
Hi All, I have come across some rather weird error that I can only assume is something to do with my ADP file connecting to SQL Server 2000. I'm using Access XP as my front end. In simple...
4
by: Beejer | last post by:
I'm running Access 2003 on WinXP Here is my problem: I'm trying to lookup a date in a table from a query data. The query include the following: Query = Qry_Invoice and Table = Tbl_Friday ...
12
by: AricC | last post by:
Howdy Errrrbody, I'm new here! I have a few questions that I can't seem to get answered, maybe you all can help. I am writing an access program ( first time I'm accustomed to .Net + Sql Server...
4
by: gps | last post by:
I'm trying to use Dmax to dip into a my invoice header table and pull the maxium invoice number out of it. I'm running Access 2007 on Vista Business, but had the same prob with Access 2003 on...
2
by: joeyrhyulz | last post by:
Hi, I'm trying to make a very simple update statement (in Oracle) in jet sql that seems much more difficult than it should be. The root of my problem is that I'm trying to update a field on a...
9
by: | last post by:
In my database I have a 'control table' in which basic info is stored about the application, for instance the application's path and the name of the company that is using it. In all of the...
15
by: rleepac | last post by:
This is a little complicated but I'll do my best to explain. In my db I have a table called L_AgeCorrection which has the following fields: Age, Sex, Frequency, AgeValue This is a table used to...
21
by: DanicaDear | last post by:
I have a report named "rptHOTSTICKS_EXPIRING" based on a query named "HOSTICKS_SHIPPING_REPORT Query". The query contains these fields: ORDER_NUM (text) CUST_NUM (text) Name, address, contact...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
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...

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.