Re: Query to find most recent date
- From: Klatuu <Klatuu@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 22 May 2008 12:06:01 -0700
Sound like your database is pretty well designed. That makes it pretty easy.
To combine them all into one query, you will need to have four queries. You
will need a totals query for each of the three you want to find the most
recent date for some event. So, for example, for the flu shot table, you
really only need to return two fields, the employee number and the Date.
When you create the query, make it a total query and use Group By for
employee number and Max for the date.
It will return one row for each employee with the most recent (maximum) date
found.
When you get those queries defind and working, create another query and join
everything on the employee number. Now you can show all the maximums for the
various tables on one row per employee.
--
Dave Hargis, Microsoft Access MVP
"LadyIlsebet" wrote:
They are text fields, or number fields, but I'm using them more as.
text. I *may* just change all the fields to text because I don't have
to do any operations on the numbers.
For instance, with the flu table, I have to track the date, as well as
a 1 letter code to describe whether they got the actual shot, turned
it down, or were given clearance to not take it due to allergies. With
the badge number table, I'm just tracking the date and the badge
number (but I don't have to do any numerical operations on the badge
number). There's an employment history table that tracks date,
position type (text) and status (text). I believe those are the only
3 where I have to know the most recent information.
Amy
On May 22, 1:38 pm, Klatuu <Kla...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
You can do this with a totals query, but to give you the right answer, I need
to know more about your data.
What are the other one or two fields and what do they contain?
--
Dave Hargis, Microsoft Access MVP
"LadyIlsebet" wrote:
I have a database with a "main" table that is linked to several
"history" tables, in one-to-many relationships. The history tables all
have an auto-number primary key, a personalID field (for employee
number), a date field, and one or two other fields (that stores
another related bit of info, like badge number, flu shot type, etc).
In the reports I'm building, I'm going to need to know the most
recently assigned badge number, date and type of most recent flu shot,
etc. I'm not sure of the best way to write these queries. Could
someone provide some guidance, please?
Thanks in advance!
Amy
- Follow-Ups:
- Re: Query to find most recent date
- From: LadyIlsebet
- Re: Query to find most recent date
- References:
- Query to find most recent date
- From: LadyIlsebet
- RE: Query to find most recent date
- From: Klatuu
- Re: Query to find most recent date
- From: LadyIlsebet
- Query to find most recent date
- Prev by Date: RE: Query Guru's, Please help Sequence Numbers in Query
- Next by Date: Re: Query to find most recent date
- Previous by thread: Re: Query to find most recent date
- Next by thread: Re: Query to find most recent date
- Index(es):
Relevant Pages
|