Results 1 to 8 of 8
  1. #1
    lochnez49 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    3

    Question Retreive only last date

    I'm using MS Access to analyze SKUs in our ERP database to determine if they are still active. To do so I export the SKU list and I'm looking at the date that the status of the SKU was last changed in the inventory organization it resides in. We have multiple inventory orgs and enable SKUs in more than one. Sometimes the SKU does not get activated in an Org and remains pending. Sometimes it will be dropped in one org but not another.



    The SKUs are created in a Master Org and then enabled in a child org. There is a Creation Date and an Effectivity Date for each. The creation date is static, but every time I change the status, the effectivity date changes. Multiple changes results in multiple effectivity dates for the same org.

    I'm trying to run a query in MS Access that will list only the last date the SKU was changed in each org. This way I can see how long a SKU has been in a particular status. What I get is every record for every effectivity date. Using the criteria [Effectivity Date] > [Creation Date] doesn't provide all records because there will be times when the SKU was never changed. Those records will not show in the results, but I need to see them.

    Can someone help me with a criteria formula or some other method of filtering for only the last effectivity date?

    Query fields are:
    SKU Descripton Inv_Org Creation_Date Status_Code Effectivity_Date

    Any suggestions are greatly appreciated.

  2. #2
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Make an aggegate query. Group by SKU (I'm guessing) and Max(effectivity date).

    I can't give you the exact query as I don't know what your tables look like.

    SELECT SKU, Max(Effectivity_Date) AS LatestDate FROM [your table or query here] GROUP BY SKU;
    Or something like that...

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,895
    Possibly need to also include Inv_Org field in the grouping.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,778
    list only the last date the SKU was changed in each org. This way I can see how long a SKU has been in a particular status
    I'm not seeing how the Max of the effective date will tell you this. Would you not need to compare the Max of the effective date against the prior effective date, but if that is non-existent (was never changed) you'd need the create date? To get the prior effective date will require a sub query IMHO. If I understand the goal, this is more complicated than what's being proposed.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Yeah, what both of those guys said. (they're much better at this than me... listen to them)

    Code:
    SELECT SKU, Inv_Org, Max(Effectivity_Date) AS LatestDate FROM [your table or query here] GROUP BY SKU, Inv_Org
    Will get you the last Effectivity Date for each SKU and Inv_Org but it doesn't tell you how long since the previous effectivity date if that's what you're after.

  6. #6
    lochnez49 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    3
    Thanks for the suggestions. I'm actually on vacation this week but will try some of what I see here when I'm back in the office.

  7. #7
    lochnez49 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    3
    Thanks again for all the input. It provided the push I needed to figure it out. I was looking at the "last" of the effective date when I needed to be looking at the "max" effective date (thanks for that!). Also, I was looking at the status code, but I needed to look at the "last" of the status code. I don't need to see when it went from Pending to Active to Inactive, only when it went to Inactive, or whatever the last status is. And to see how long it's been in that status, not how long it was between changes.

    Again, thanks!

  8. #8
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,778
    Where I used to work, StatusUpdate was a field common to many tables, and it's purpose was to know when it was put into whatever the current status was. Easy enough to compare that date to a current date and know how long it has been in a particular status. However, there were a few metrics that would have been possible if there was a date per status - such as how long it took for a work order to be approved after it was submitted for approval. This isn't possible when the StatusDate gets updated at every change. I thought you wanted something more complicated than what you seem to have arrived at. Glad you got it solved anyway.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 11-10-2014, 09:47 AM
  2. Retreive Access Password
    By katmac in forum Access
    Replies: 3
    Last Post: 11-28-2013, 12:55 PM
  3. Retreive Blank Form upon Record Entry
    By michael.legge@rbc.com in forum Access
    Replies: 2
    Last Post: 07-12-2013, 02:26 PM
  4. Replies: 3
    Last Post: 07-10-2013, 11:58 AM
  5. Replies: 3
    Last Post: 08-21-2012, 03:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums