Page 2 of 2 FirstFirst 12
Results 16 to 24 of 24
  1. #16
    rfigueroa1976 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2017
    Posts
    34
    Still getting a syntax error.


    SELECT dbo_orderheader.ord_number AS [Order Number], dbo_orderheader.ord_refnum AS [Reference Number], dbo_NCR_Occurrence.BookingTerminal AS [Booking Terminal], dbo_orderheader.ord_origin_latestdate AS [Scheduled Loading Date], dbo_orderheader.ord_startdate AS [Actual Loading Date Date], dbo_orderheader.ord_dest_latestdate AS [Scheduled Delivery Date], dbo_orderheader.ord_completiondate AS [Actual Delivery Date], dbo_company_1.cmp_name AS [Shipper Name], dbo_city.cty_name AS [Shipper City], dbo_city.cty_state AS [Shipper State], dbo_company.cmp_name AS Consignee, dbo_city_1.cty_name AS [Consignee City], dbo_city_1.cty_state AS [Consignee State], dbo_NCR_Occurrence.EnteredBy AS [NCR Created By], dbo_NCR_Occurrence.NCR_ID AS [NCR ID], dbo_NCR_Occurrence.CustomerComplaintNumber AS [Customer Complaint Number], dbo_NCR_Occurrence.OccurrenceDate AS [Occurrence Date], dbo_NCR_IncidentTypes.Description AS [Incident Type], dbo_NCR_RootCauses.Description AS [Root Cause], dbo_NCR_PreventiveActions.Description AS [Preventive Action], Switch (dbo_NCR_RootCauses.Description LIKE "Carrier*", "1-Carrier", dbo_NCR_RootCauses.Description LIKE "Shipper*", "2-Shipper", dbo_NCR_RootCauses.Description LIKE "Consignee*", "3-Consignee", dbo_NCR_RootCauses.Description LIKE "Unforeseen*", "4-Unforeseen",TRUE, "5-Other")" AS [Fault Hierarchy]
    FROM (((((((dbo_NCR_Occurrence INNER JOIN dbo_NCR_RootCauses ON dbo_NCR_Occurrence.RootCause_ID = dbo_NCR_RootCauses.RootCause_ID) INNER JOIN dbo_orderheader ON dbo_NCR_Occurrence.OrderNumber = dbo_orderheader.ord_number) INNER JOIN dbo_NCR_IncidentTypes ON dbo_NCR_Occurrence.IncidentType_ID = dbo_NCR_IncidentTypes.IncidentType_ID) INNER JOIN dbo_company AS dbo_company_1 ON dbo_orderheader.ord_shipper = dbo_company_1.cmp_id) INNER JOIN dbo_city ON dbo_company_1.cmp_city = dbo_city.cty_code) INNER JOIN dbo_company ON dbo_orderheader.ord_consignee = dbo_company.cmp_id) INNER JOIN dbo_NCR_PreventiveActions ON dbo_NCR_Occurrence.PreventiveAct_ID = dbo_NCR_PreventiveActions.PreventiveAct_ID) INNER JOIN dbo_city AS dbo_city_1 ON dbo_company.cmp_city = dbo_city_1.cty_code
    WHERE (((dbo_orderheader.ord_origin_latestdate) Between [start] And [end]) AND ((dbo_NCR_RootCauses.Description) Not Like "*internal*") AND ((dbo_NCR_Occurrence.CustomerName) Like "*arclin*") AND ((dbo_NCR_Occurrence.BilltoName) Like "*arclin*") AND ((dbo_NCR_Occurrence.Status_ID) Not Like "26"))


    ORDER BY dbo_city.cty_name, dbo_NCR_RootCauses.Description;

  2. #17
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Why bother with alias field names?

    Are you using query builder to construct the SQL?

    LIKE without wildcard might as well use = or in this case <>:

    AND ((dbo_NCR_Occurrence.Status_ID) <> "26"))

    Status_ID is a text field? If it is number type, remove the quote marks.
    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. #18
    rfigueroa1976 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2017
    Posts
    34
    The wildcard ( "*" ) covers the multiple results that could come. Carrier - Dispatch error, Carrier - Capacity, Carrier - Driver attitude, etc. Each of them could be one of hundreds. This is why i'm trying to bring it down to 5 faults.

  4. #19
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Was referring to just the Status_ID using LIKE without wildcard.
    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. #20
    rfigueroa1976 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2017
    Posts
    34
    I'm lost June. What do you mean?

    What i need to happen is have a formula/command/whatever look at the result of the root cause description field which could be one of hundreds. For the most part, the root cause will start with any of the four previously mentioned (Carrier, shipper, consignee, unforeseen). If the root cause description result starts with Carrier, i want the field/cell next to it to show as "1-Carrier", If starts with Consignee, show at "2-Consignee", etc.

    Each of the root causes could have several that start with the same word but end differently; meaning, there could be over 100 root causes that start with the word Carrier. I want the fields/cells next to those labeled as "1-Carrier".

  6. #21
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    I don't see anything wrong with the root causes calculation. My comment specifically addressed the criteria: AND ((dbo_NCR_Occurrence.Status_ID) Not Like "26")) which uses LIKE without a wildcard.
    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.

  7. #22
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    As mentioned before, shouldn't use reserved words as object names.
    "Description", "Start" and "End" are reserved words.
    Code:
    WHERE (((dbo_orderheader.ord_origin_latestdate) Between [start] And [end]) AND
     ((dbo_NCR_RootCauses.Description) Not Like "*internal*") AND
    
    (plus other tables that have "Description" as a field name)

    It looks like you have an extra double quote in the Switch function:
    Code:
    <snip>
    Switch (
            dbo_NCR_RootCauses.Description LIKE "Carrier*"    , "1-Carrier", 
            dbo_NCR_RootCauses.Description LIKE "Shipper*"    , "2-Shipper", 
            dbo_NCR_RootCauses.Description LIKE "Consignee*"  , "3-Consignee", 
            dbo_NCR_RootCauses.Description LIKE "Unforeseen*" , "4-Unforeseen",
            TRUE                                              , "5-Other")"  <<-- last double quote should be deleted 
    
    AS [Fault Hierarchy]<snip>

    Still an error?
    Try creating another query, but without the WHERE clause. Execute it. Does it error?
    If yes, start deleting fields in the SELECT clause until the error is gone. Fix the error.
    If No, add one condition/criteria to the WHERE clause. Execute it. Error?
    Add one condition until you get an error.
    Fix the error.

  8. #23
    rfigueroa1976 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2017
    Posts
    34
    IT WAS THE DOUBLE QUOTE! Thank god this finally worked! Thank you all SOOOOOOOO MUCH for your help and patience with this. I truly appreciate you all!

  9. #24
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Happy you got it working....


    Ready to mark this solved?

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

Similar Threads

  1. Labeling Page 2 of a report?
    By PATRICKPBME in forum Reports
    Replies: 14
    Last Post: 07-20-2017, 10:32 AM
  2. Labeling an icon on my dashboard
    By PATRICKPBME in forum Access
    Replies: 2
    Last Post: 05-01-2017, 01:00 PM
  3. Tool Check Out and labeling small items
    By WDD in forum Database Design
    Replies: 5
    Last Post: 11-29-2014, 10:57 PM
  4. Labeling command buttons
    By SemiAuto40 in forum Forms
    Replies: 6
    Last Post: 07-17-2012, 11:03 AM
  5. labeling multiple copies
    By tgavin in forum Reports
    Replies: 1
    Last Post: 05-11-2011, 05:07 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