Results 1 to 2 of 2
  1. #1
    shelzmike is offline Novice
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2010
    Posts
    22

    Query Criteria dependant on partial string in another field

    I am pretty much a newb at creating my own queries but can understand most that are already put together.



    Anyhow, I have a simply query that is pulling info from a couple of tables and I need help on determining how to specifiy the criteria (or understanding at least if this can be done).

    Here is the code:

    Code:
     
    PARAMETERS [Start Date] DateTime, [End Date] DateTime;
    SELECT [TBL_ACTIVE WO].[TECH NUMBER], [TBL_ACTIVE WO].[CSG LAST CHANGED DATE], [TBL_ACTIVE WO].[WORK ORDER TYPE], [TBL_ACTIVE WO].[CSG ACCT NUMBER], [TBL_ACTIVE WO].[WORK ORDER NUMBER], [TBL_ACTIVE WO].[CSG STATUS], [TBL_ACTIVE WO].[WO COMPLETION DATE], [TBL_ACTIVE WO].CONNECTIVITY, [TBL_ACTIVE WO].[SERVICE CODES]
    FROM [TBL_ACTIVE WO] INNER JOIN [TBL_CUSTOMER ACCOUNT INFO] ON [TBL_ACTIVE WO].[CSG ACCT NUMBER] = [TBL_CUSTOMER ACCOUNT INFO].[CSG ACCT NUMBER]
    WHERE ((([TBL_ACTIVE WO].[CSG LAST CHANGED DATE]) Between [Start Date] And [End Date]) AND (([TBL_ACTIVE WO].[WORK ORDER TYPE])="NC" Or ([TBL_ACTIVE WO].[WORK ORDER TYPE])="CH") AND (([TBL_ACTIVE WO].CONNECTIVITY) Is Not Null))
    ORDER BY [TBL_ACTIVE WO].[CSG LAST CHANGED DATE];
    What I want to be able to do is pull the Work Orders whose status is CH ONLY if the string of |Z8| is present in the Service Codes field. How do I accomplish a.) querying the Code field for just that part of the field, and b.) pull only CH's if that part is present?

    By the way, here is what a code field looks like (granted, the codes can be diversely different, depending on the job)

    .D|(5|/A|??|AA|HQ|}{|OR|PZ|P2|Y:|YI|ZH|Z8|1A|1D|1V|2U|4S| 4W|6P|78|AC|PZ|9:|CG|}T

    Thanks!

    Mike

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Check out the InStr() function in help. Sounds like a criteria of

    ...(Status = "CH" AND InStr(...) > 0)...

    would work for you.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Query multiple field & criteria
    By fua in forum Access
    Replies: 2
    Last Post: 11-04-2009, 08:22 PM
  2. Replies: 3
    Last Post: 06-03-2009, 07:15 AM
  3. query - criteria based on another row field value
    By techexpressinc in forum Queries
    Replies: 1
    Last Post: 05-29-2009, 04:17 PM
  4. Partial Matching based Queries
    By Yatesb in forum Queries
    Replies: 0
    Last Post: 02-23-2009, 01:06 PM
  5. Extract numbers from text string strored in a field.
    By khabdullah in forum Programming
    Replies: 2
    Last Post: 12-23-2007, 06:55 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