Results 1 to 5 of 5
  1. #1
    MsAxes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Posts
    100

    How to determine order of two fields?

    I have a table with field CustA and CustB, both fields are text/number combination (see example below). There are times (rare) where a field can be blank.

    CustA CustomB
    asd123456egfpl 21564zsdfaweq
    pk21654sw5121 plsad15646512
    12wasd1456712 0odsafa131asd1
    54dwesa564646

    I also have a table named Sort Order. The purpose of this table is to identify which customer is first based on the order number the character has.

    order Character
    1 z
    2 y
    3 x
    4 w
    5 v
    6 u
    7 t
    9 s

    So I would like a new field (Flag) to tell me which customer is first based on the Sort Order table. Example, if CustA has the letter z before CustB then CustA is first based on the table. If they both have Z in the same occurrence, then continue looking at the Sort Order table until one has a character in the order before the other.



    CustA CustomB Flag
    asd123456egfpl a1564zsdfaweq CustA First
    uk21654sw5121 wlsad15646512 CustB First
    12wasd1456712 0odsafa131asd1 CustA First
    54dwesa564646 One record is null

    I tried to Google and look for examples and can't find anything to get started.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    I think this will need a VBA custom procedure.
    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.

  3. #3
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,122
    How\why is CustA first in the first row example? B has "z" in position 6.
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    Maybe letter must be in both strings. First letter in both strings of record 1 is "s" and it is in 2nd position in CustA, 7th in CustB. Dang, that falls apart in 3rd record.
    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.

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,445
    why does this feel like an exercise that has nothing to do with customers, the data is nothing like what is being shown and there will be all sorts of other issues not covered

    explain how you have determined which customer is first - on the first line you said

    Example, if CustA has the letter z before CustB then CustA is first based on the table.
    So CustA does not have a z, but is first- why?

    Does case matter? ('Z' v 'z')
    are numbers to be ignored?
    are strings always of the same length - or doesn't it matter?



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

Similar Threads

  1. Replies: 1
    Last Post: 01-24-2020, 02:49 PM
  2. Replies: 3
    Last Post: 08-22-2018, 11:05 AM
  3. Replies: 4
    Last Post: 07-18-2016, 12:59 PM
  4. Replies: 1
    Last Post: 08-13-2013, 09:39 PM
  5. Replies: 4
    Last Post: 07-12-2011, 09:49 AM

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