I am using ODBC to populate an Access table. The linked tables are in a
separate ERP software table set.
The Linked table in question tracks the various phases of an order and who
made the transaction (transaction being an event in the status/location of
an order). For example, when a person enters an order, their ID and a time
stamp is added to the transaction. Then, a separate person scans the order
into the manufacturing plant, then a person scans it as complete, etc.
Example:
OrderID Status Employee
Time
1234 OrderEntered Tom 020305
12:34:44
1234 In Mfg. Dan
020305 13:24:55
1234 Completed Steve
020505 07:31:22
However, it sometimes happens that an order is scanned back to a previous
process in order for a change to be made (the software won't allow certain
changes to be made unless an order is scanned into the right location or
process). So the ERP table may have:
OrderID Status Employee
Time
1234 OrderEntered Tom 020305
12:34:44
1234 In Mfg. Dan
020305 13:24:55
1234 Modified Tony
020405 01:33:13
1234 In Mfg. Tony
020405 01:44:35
1234 Completed Steve
020505 07:31:22
So, for any OrderID, an order might be scanned to the same location more
than once. What I want to do is update the Access table, but then also
delete DUPLICATE scanpoints/status entries and retain the FIRST one. So,
when the ERP table has:
OrderID Status Employee
Time
1234 OrderEntered Tom 020305
12:34:44
1234 In Mfg. Dan
020305 13:24:55
1234 Modified Tony
020405 01:33:13
1234 In Mfg. Tony
020405 01:44:35
1234 Completed Steve
020505 07:31:22
My Access table would have:
OrderID Status Employee
Time
1234 OrderEntered Tom 020305
12:34:44
1234 In Mfg. Dan
020305 13:24:55
1234 Modified Tony
020405 01:33:13
1234 Completed Steve
020505 07:31:22
(keeping the FIRST instance of Status="In Mfg" but deleting the subsequent
ones.
How would I set up a query to do this? It's basically saying "For every
Status Entry, if there is more than one of the same status in the same
OrderID, keep the earliest TimeStamp one and delete the others"
Thanks for any help, it is appreciated.