Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    None of the sample records have that situation.

    So which field should take precedence - which code should the Y fall under? If you want it under both, this gets more complicated. Will require a UNION query then use the UNION as source for the CROSSTAB. There is no builder or wizard for UNION, must type or copy/paste in SQLView.

    SELECT tracking_number, invoice_number, charge_description_code AS Code FROM shipment_details
    UNION SELECT tracking_number, invoice_number, charge_description FROM shipment_details;

    Then:

    TRANSFORM Nz(Max(IIf([code] In ('AHS','AHW','RES','SAT',"CWT"),"Y","N")),"N") AS Data
    SELECT Query1.tracking_number, Query1.invoice_number
    FROM Query1
    GROUP BY Query1.tracking_number, Query1.invoice_number


    PIVOT Query1.code In (SAT,AHW,AHS,RES,CWT);
    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.

  2. #17
    NSearch is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    62
    The output will now have 7 fields:

    tracking_number, invoice_number, SAT, AHW, AHS, RES, CWT

    if a tracking number/invoice number pair has cwt in the charge_description, CWT will be set to Y and could also have a Y flag set for any of the other 4 (SAT, AHW, AHS, RES)

    Attached is an updated example where you should see a CWT flag set to Y and a RES flag set to Y

    Testing_v3.zip

  3. #18
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    I edited previous post, possibly after you read it. Review again.
    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. #19
    NSearch is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    62
    Ok, I think I have that part down.

    Can you add in the part of the Like statement. I am not sure where to put that.

    I need to identify anything that has 'cwt' in the field. It could be 'xxxx cwt' or 'zzzz cwt' or 'yyyy cwt' etc..


    I think it might be:

    SELECT tracking_number, invoice_number, charge_description_code AS Code FROM shipment_details
    UNION SELECT tracking_number, invoice_number, iif(Instr(charge_description,'cwt'),'CWT','') FROM shipment_details;

  5. #20
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    UNION SELECT tracking_number, invoice_number, iif(Instr(charge_description,'cwt')>0,'CWT',") FROM shipment_details;
    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.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 03-13-2012, 06:11 PM
  2. Replies: 6
    Last Post: 02-27-2012, 01:27 PM
  3. Replies: 4
    Last Post: 10-28-2011, 12:49 PM
  4. Combine values from multiple fields
    By jsimard in forum Queries
    Replies: 8
    Last Post: 06-09-2011, 01:05 PM
  5. Combine the values of two fields on a form
    By nyteowl in forum Access
    Replies: 4
    Last Post: 10-15-2010, 11:16 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