Results 1 to 10 of 10
  1. #1
    DaveMSAccess is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Dec 2018
    Posts
    5

    serialize or rank individual values in a query


    Hi, I'm looking for a relatively simple way to serialize values in a query. My data has 3 key fields, Warehouse, Item and Code Date. I would lie to label or rank the Code Date within each Item and Warehouse as 1,2,3,,,, I am not familiar with VB or SQL, would like to use standard functions if possible. In my mind, the data would look like this:

    WAREHOUSE ITEM CODE DATE RANK SumOfLYQTY FirstOfCurrent Date Expr1
    1 01500 20190325 1 1254 20181218 -1
    1 01500 20190401 2 3328 20181218 -1
    1 01500 20190408 3 3520 20181218 -1
    2 01500 20190325 1 1969 20181218 -1
    2 01500 20190401 2 4032 20181218 -1
    2 01500 20190408 3 3264 20181218 -1

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    It appears that your sample data is ordered by WarehouseID and CodeDate.
    You could use an Order By clause in your Query.

    If you are using the query grid, then these fields would be in the Sort row of the grid.

  3. #3
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,120
    You will need to do an aggregate query where you group by warehouse and sort by Code Date
    If you need to create a Rank order field then you need an additional step

    Rank order can easily be done in reports but needs a bit more work in queries

    Have a look at the Rank Order in Queries page on my website http://www.mendipdatasystems.co.uk/r...ies/4594424063
    It includes the use of a Serialize function and several examples

    Another approach involves the use of subqueries - Allen Browne explains this in some detail here: http://allenbrowne.com/ranking.html
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  4. #4
    DaveMSAccess is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Dec 2018
    Posts
    5

    Yes, but...

    Quote Originally Posted by orange View Post
    It appears that your sample data is ordered by WarehouseID and CodeDate.
    You could use an Order By clause in your Query.

    If you are using the query grid, then these fields would be in the Sort row of the grid.
    Yes, but that doesn't address the Rank or numbering of the records. I need that to create a cross-tab that isn't 100 fields wide. I got a link from another member, trying that.

  5. #5
    DaveMSAccess is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Dec 2018
    Posts
    5

    Thanks

    Yes, your post gave me all of the info I need.

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,120
    Excellent. Which method did you decide to use for your solution?
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  7. #7
    DaveMSAccess is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Dec 2018
    Posts
    5

    Hmmmmm...

    Quote Originally Posted by ridders52 View Post
    Excellent. Which method did you decide to use for your solution?
    Still working on it. How can I reference other records in a query (the previous record)? If I can't do that, I may need to 'kluge' it.

  8. #8
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,120
    Once again using Serialize or using a subquery.
    See http://www.mendipdatasystems.co.uk/g...lue/4594484854 for the first approach with a link to the second.

    If you have a lot of records and find those methods slow, you could write a function specifically for the purpose if necessary
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  9. #9
    DaveMSAccess is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Dec 2018
    Posts
    5
    Quote Originally Posted by ridders52 View Post
    Once again using Serialize or using a subquery.
    See http://www.mendipdatasystems.co.uk/g...lue/4594484854 for the first approach with a link to the second.

    If you have a lot of records and find those methods slow, you could write a function specifically for the purpose if necessary
    OK, I get it now, thanks.

  10. #10
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Dave can you post your solution. It might help someone else.

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

Similar Threads

  1. Replies: 1
    Last Post: 04-04-2017, 06:54 AM
  2. Replies: 9
    Last Post: 08-25-2015, 01:04 PM
  3. Replies: 7
    Last Post: 08-29-2014, 12:02 PM
  4. Replies: 3
    Last Post: 01-25-2011, 09:50 AM
  5. How to Serialize Recs in a table
    By access230 in forum Access
    Replies: 3
    Last Post: 08-26-2009, 02:28 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