Results 1 to 10 of 10
  1. #1
    shod90 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    134

    Find last item in table with specific criteria

    Dear Gents,
    I have a table that stores some items like the following.
    ID Mask ID Company
    1 1A
    2 2A
    3 1B
    4 3A



    i Need a formula that returns the last maskID which ends with "B" , How should be done ?
    Thanks

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,933
    Use DMax() ?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,428
    Suspect your example data is too simplistic. Last has no meaning without an order so need to know last in terms of what? Per your example that would in terms of ID and would return the record where ID=3.

    And since your mask ID is a number followed by a letter, sorting will be a string sort so if you have

    5B
    22B
    333B

    5B will be last

  4. #4
    shod90 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    134
    Quote Originally Posted by Welshgasman View Post
    Use DMax() ?
    unfortunately you didn't read my post well

  5. #5
    shod90 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    134
    Quote Originally Posted by Ajax View Post
    Suspect your example data is too simplistic. Last has no meaning without an order so need to know last in terms of what? Per your example that would in terms of ID and would return the record where ID=3.

    And since your mask ID is a number followed by a letter, sorting will be a string sort so if you have

    5B
    22B
    333B

    5B will be last
    Actually after 5B we should add 6B and 7B etc , But between them the other maskID which ends with A

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,428
    OK so you will never go over 9B?

    if you did, you are OK for adding ....4B, 5B, 6B, 7B, 8B,9B but if you add 10B, 9B will still be last

    Or are you saying if your data looked like this, you still want 1B returned

    ID Mask ID Company
    1 1A
    2 3B
    3 1B
    4 3A

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,933
    Quote Originally Posted by shod90 View Post
    unfortunately you didn't read my post well
    For what you posted that would work? I'm not a mind reader.
    However you would still have the issue that 5B would be greater than 22B
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  8. #8
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Please have a look at Query1 in attached file.

    Cheers,
    Attached Files Attached Files
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  9. #9
    shod90 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    134
    PERFECT , That's what I want , Thanks.

  10. #10
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    You're very welcome, good luck with your project!

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Replies: 1
    Last Post: 03-09-2018, 01:26 PM
  2. Replies: 3
    Last Post: 05-10-2017, 12:45 PM
  3. Replies: 5
    Last Post: 04-23-2015, 10:23 AM
  4. Replies: 2
    Last Post: 09-20-2014, 11:28 AM
  5. Replies: 1
    Last Post: 02-19-2014, 05:49 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