Results 1 to 6 of 6
  1. #1
    sfgiantsdude is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    34

    IF/THEN statement problem

    A bit of a complicated issue: I wrote this statement to test whether a row should be given a value under the Expr5 column of "TEST or "EXCLUDE". I only want this if/then statement to apply to Q42011 and beyond (hence the exclusion of 113-101) but I'm getting "EXCLUDE" values to rows that are within the Q12010-Q32011 when I really don't even want them to be included in my IF/THEN column. I'd rather they show up blank. Any suggestions?



    Expr5: IIf(([MCA_EPM_ISSUES]![KP_YR_NB] & Right([MCA_EPM_ISSUES]![QTR],2)) Not In ("113","112","111","104","103","102","101") And [REF - Department V2]![REPORTING_DEPT] In ("LABORATORY","RADIOLOGY") And [MCA_EPM_ISSUES]![SUB_DEPT] Like "*HOV*","TEST","EXCLUDE")

  2. #2
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071
    The way the IIF statement is written gives the following results

    If Not in 113-101 and reporting dept in lab radiology and subdept like *HOV* Then
    Test
    Else
    Exclude
    End if

    From your description what your trying to get is

    If Not in 113-101 Then
    If reportingdept in lab,radiology and subdept like HOV Then
    "Test"
    Else
    "EXCLUDE"
    End if
    Else
    ""
    End if

    so your statement should be
    Expr5: IIf(([MCA_EPM_ISSUES]![KP_YR_NB] & Right([MCA_EPM_ISSUES]![QTR],2)) Not In ("113","112","111","104","103","102","101") ,IIF( [REF - Department V2]![REPORTING_DEPT] In ("LABORATORY","RADIOLOGY") And [MCA_EPM_ISSUES]![SUB_DEPT] Like "*HOV*","TEST","EXCLUDE"),"")

  3. #3
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Could you provide some of the data that are in the two fields [KP_YR_NB] and [QTR] as an example? I'm having a hard time understanding how you get from something like Q42011 to 113, 112 etc.

  4. #4
    sfgiantsdude is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    34
    KP_YR_NB has data related to year, like "2011" "2010" "2009" etc. The QTR variable just has the quarterly number whether it be 1,2,3,4. So the concatenation of the two should produce 113, 112, 104, etc. However I just noticed that I did the right cutoff for the wrong variable so I need to fix that.

  5. #5
    sfgiantsdude is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    34
    RayMilhon: That worked! Thanks very much for your assistance. It's greatly appreciated!

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Might help to show sample data. Why are you concatenating and using Right - Q42011 is not a single field value? Why not simply: [fieldname] > "Q42011"?

    You have created an expression that returns a value for each and every record, now you can use value to filter records. The filter criteria would be: "TEST".

    Alternatively, break this up to show criteria under each of the fields.

    EDIT: I did not see other posts before sending mine. Glad you found solution.
    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.

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

Similar Threads

  1. problem with IF THEN statement in access 2003 query
    By sfgiantsdude in forum Access
    Replies: 4
    Last Post: 01-05-2012, 04:23 PM
  2. Problem with a IIF statement
    By Genzo in forum Access
    Replies: 10
    Last Post: 08-31-2011, 10:46 AM
  3. problem with my DoCmd.RunSQL statement
    By cgclower in forum Access
    Replies: 1
    Last Post: 07-24-2011, 06:12 PM
  4. Me.Filter statement problem.
    By BobG in forum Programming
    Replies: 2
    Last Post: 11-19-2010, 10:25 AM
  5. Problem With IF Statement
    By MuskokaMad in forum Programming
    Replies: 0
    Last Post: 03-14-2010, 05:26 PM

Tags for this Thread

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