MS Access

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Jeff Klein

Thread Starter
Joined
May 28, 2001
Messages
5
I need to create a query that shows the last state that a employee has visited. The entire row with all columns must show in the query.

The original table columns: Name, Date, State, Reason, and Expense.

The resulting information is to be used in a linked word document.
(this I can do)

Can anyone help...point me in some direction...

Thanks, Jeff
 
Joined
Jul 29, 2001
Messages
21,334
Is there a field in any of your tables that has the last state visited information? If there is a new recrd created each time they visit a state than you could set the filter to the last record for that employee.
 
Joined
Feb 12, 2001
Messages
3,420
SELECT MyTable.Name, MyTable.State, MAX(MyTable.Date)
FROM MyTable
GROUP BY MyTable.Name, MyTable.State

This should pull out a listing of all Employees and the last state they visited...
 
Joined
Oct 13, 2000
Messages
941
Hi. Don't know if you worked this out yet, but I don't see the "right" answer, so I'll pretend you haven't... :)

The thing is, you cannot get from the same table both the maximum date and the related state as th suggests in a single query; what you have to do is build two queries.

Query 1 is an aggregate query, as th suggests, but pulls only name (terrible field names, by the way--read here to find out why) and max date. Otherwise, if you group by state as well, you'll get the last date that each name visited each state.

Save the first query with whatever name you like. I'm pretending it's called qryLastVisitDte.

Query 2 includes the original table and qryLastVisitDte. You link the Name and the MaxOfDate fields in qryLastVisitDte to the related fields in your table, and that will pull the state related to each date and name. Of course, this will only work as long as no one visited more than one state in a day...
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top