T
Todd
I have the following two tables:
TblStatus
with fields StatID (autonum), VessNum, StatDate, Status,
Location
example data
StatID, VessNum, StatDate, Status, Location
1,V-1, 1/1/03, Empty, Storage
2,V-1, 1/3/03, Full, Rm101
3,V-1, 1/3/03, Cleaned, n/a
3,V-2, 1/12/03, Empty, Storage
4,V-2, 1/15/03, Full, Rm 101
TblLocPickList
with fields LocID, Location, Status
example data
LocID, Location, Status
1, Storage, Empty
2, Off-Site, Empty
11, n/a, Cleaned
12, Rm101, Cleaned
20, Rm101, Full
21, Rm202, Full
The LocID field in TblLocPickList is not an autonumber
field, it is set up so that the Status items are ordered
in the sequential order that they should occur for our
workflow. Note: this also feeds a combo box on a status
entry form.
I'm trying to write a query that will return the latest
status for each vessel. In the case of the example data
above, the query should return:
VessNum, StatDate, Status, Location
V-1, 1/3/03, Full, Rm101
V-2, 1/15/03, Full, Rm101
As you can from the example data, there is sometimes a
status change that occurs in the same day for a a
particular vessel, I only want to return the latest
status.
The problem I'm having is distinguishing the latest status
update for vessels that have multiple status changes on
the same day. I've been able to solve it by choosing the
Max(StatID), however, this forces the data entry to be
made in the actual order that the status events occur. It
would be better if the query could work regardless of the
data entry order (could be that one data entry person
enters the cleaning event, and another enters the filling
event depending on how the paperwork goes.)
I think that this could work by using the table
TblLocPickList to identify the last event that should have
occured (ie Max(LocID)). The process workflow always is
in this order.
I've tried to do this unsuccessfully.
Can anyone help?
TblStatus
with fields StatID (autonum), VessNum, StatDate, Status,
Location
example data
StatID, VessNum, StatDate, Status, Location
1,V-1, 1/1/03, Empty, Storage
2,V-1, 1/3/03, Full, Rm101
3,V-1, 1/3/03, Cleaned, n/a
3,V-2, 1/12/03, Empty, Storage
4,V-2, 1/15/03, Full, Rm 101
TblLocPickList
with fields LocID, Location, Status
example data
LocID, Location, Status
1, Storage, Empty
2, Off-Site, Empty
11, n/a, Cleaned
12, Rm101, Cleaned
20, Rm101, Full
21, Rm202, Full
The LocID field in TblLocPickList is not an autonumber
field, it is set up so that the Status items are ordered
in the sequential order that they should occur for our
workflow. Note: this also feeds a combo box on a status
entry form.
I'm trying to write a query that will return the latest
status for each vessel. In the case of the example data
above, the query should return:
VessNum, StatDate, Status, Location
V-1, 1/3/03, Full, Rm101
V-2, 1/15/03, Full, Rm101
As you can from the example data, there is sometimes a
status change that occurs in the same day for a a
particular vessel, I only want to return the latest
status.
The problem I'm having is distinguishing the latest status
update for vessels that have multiple status changes on
the same day. I've been able to solve it by choosing the
Max(StatID), however, this forces the data entry to be
made in the actual order that the status events occur. It
would be better if the query could work regardless of the
data entry order (could be that one data entry person
enters the cleaning event, and another enters the filling
event depending on how the paperwork goes.)
I think that this could work by using the table
TblLocPickList to identify the last event that should have
occured (ie Max(LocID)). The process workflow always is
in this order.
I've tried to do this unsuccessfully.
Can anyone help?