Results 1 to 6 of 6
  1. #1
    bandidom9 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    6

    Expression too complex

    I need to do this query. Is there a way to make it simpler so wont get the complez expression message?

    SELECT UIC, CCtr,

    IIf (CCtr LIKE "230A?00*" OR CCtr LIKE "230A?N09*" OR CCtr LIKE "230A?N03*", "N00/09/03",
    IIf (CCtr LIKE "230A?N0AL*", "N00AL",
    IIf (CCtr LIKE "230A?N04%", "N04",
    IIf (CCtr LIKE "230A?N05*", "N05",
    IIf (CCtr LIKE "230A?N1*", "N1",
    IIf (CCtr LIKE "230A?NTEN0*", "N10",
    IIf (CCtr LIKE "230A?N3*" OR CCtr LIKE "230A?N4*", "N3/4",
    IIf (CCtr LIKE "230A?N5*", "N5",
    IIf (CCtr LIKE "230A?N6*", "N6",
    IIf (CCtr LIKE "230A?N7*", "N7",
    IIf (CCtr LIKE "230A?N8*", "N8",


    IIf (CCtr LIKE "230A?N91*", "N91",
    IIf (CCtr LIKE "230A?N0CC*", "NOCC",
    IIf (CCtr LIKE "230A?N0GC*", "NOGC",
    IIf (CCtr LIKE "230A?OP*", "NOP")))))))))))))) AS DivCode

    FROM [Quarterly Report]
    WHERE ( UIC LIKE "*23" OR UIC = "3598A");

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Can you tell us in plain English what you are trying to do?

    My first impression is that you have a custom code (identifier or whatever) that includes at least 2 concepts, When you want to use that custom code, you have to parse it to separate the fields/concepts.

    Seems like a design issue.

  3. #3
    bandidom9 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    6
    Plain english is not my first language........ More than a database im usin acces as a report creator. I receive a excel sheet with data that have the CCtr fiel on it. that fiel contains an ID from wich a division can be identified. I want this query to create the same sheet with an new field displaying the division code. If i erase one line from the code the code works perfectly. It seems that i just went over some sort of limit. by just one line.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    OK, so it seems you do have some sort of processed data in the text file and you are bringing it into Access. Then separating out some values to create DivCodes.

    You are basically doing a Lookup on these incoming CCtr field values.

    If the CCtr values are known, you could build a table in Access - let's call it tblDivCodesToDisplay.

    It would have fields
    IncomingCCtr text
    OutputDivCode text

    You could populate that table with queries based on the values you have in the many IIF statements.

    Then you could revise the query to include the new table -- something along these lines --
    ---untested----air code ----
    SELECT UIC, CCtr, outputDivCode
    FROM [Quarterly Report] inner join tblDivCodesToDisplay
    ON [Quarterly Report].CCtr = tblDivCodesToDisplay.IncomingCCtr
    WHERE
    UIC LIKE "*23" OR UIC = "3598A"

  5. #5
    bandidom9 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    6
    The values are known but i have to be able to use wildcards. What a did to overcome the nexted if limit is I created a Funtion and it worked! Thanks for the help i really appreciated.

    Public Function Code(CC As String)
    If (CC Like "230A?00*" Or CC Like "230A?N09*" Or CC Like "230A?N03*") Then
    Code = "N00/09/03"
    ElseIf (CC Like "230A?N0AL*") Then
    Code = "N00AL"
    ElseIf (CC Like "230A?N04*") Then
    Code = "N04"
    ElseIf (CC Like "230A?N05*") Then
    Code = "N05"
    ElseIf (CC Like "230A?N1*") Then
    Code = "N1"
    ElseIf (CC Like "230A?NTEN0*") Then
    Code = "N10"
    ElseIf (CC Like "230A?N3**" Or CC Like "230A?N4*") Then
    Code = "N3/4"
    ElseIf (CC Like "230A?N5*") Then
    Code = "N5"
    ElseIf (CC Like "230A?N6*") Then
    Code = "N6"
    ElseIf (CC Like "230A?N7*") Then
    Code = "N7"
    ElseIf (CC Like "230A?N8*") Then
    Code = "N8"
    ElseIf (CC Like "230A?N91*") Then
    Code = "N91"
    ElseIf (CC Like "230A?N0CC*") Then
    Code = "NOCC"
    ElseIf (CC Like "230A?N0GC*") Then
    Code = "NOGC"
    ElseIf (CC Like "230A?OP*") Then
    Code = "NOP"
    End If
    End Function

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

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

Similar Threads

  1. Expression to complex
    By Compufreak in forum Queries
    Replies: 5
    Last Post: 08-08-2012, 04:03 AM
  2. Replies: 1
    Last Post: 05-24-2012, 12:34 PM
  3. Expression too complex to Evaluate
    By cbh35711 in forum Access
    Replies: 4
    Last Post: 02-27-2012, 11:06 AM
  4. Replies: 3
    Last Post: 03-31-2011, 11:07 AM
  5. need help, expression is too complex?
    By ice673 in forum Queries
    Replies: 5
    Last Post: 02-15-2010, 09:03 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