Results 1 to 6 of 6
  1. #1
    anoble1 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    7

    IF OR Statement help

    I need some help, I keep getting errors in my query when I add a or as in it doesn't display what I am looking for.
    Code:
    Expr1: IIf([dbo_vw_ReportingInfo]![Location Type]="FULL SERVICE" Or "LIMITED ACCESS","FULL","OTHER")
    This is the Column Heading of a crosstab query. I would like there to be 2 columns at the top. First column would be "Full" which would include the Location Types of: Full Service or Limited Access. The second column would add all other types up. When I run the query as is it just has 1 column for full service.

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Try these:
    Code:
    IIf([dbo_vw_ReportingInfo]![Location Type]="FULL SERVICE" Or [dbo_vw_ReportingInfo]![Location Type]= "LIMITED ACCESS","FULL","OTHER")
    Code:
    IIf([dbo_vw_ReportingInfo]![Location Type] IN ("FULL SERVICE","LIMITED ACCESS"),"FULL","OTHER")
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,422
    Each portion needs to be able to stand on it's own. Your second portion says Or "LIMITED ACCESS". If I walked up to you and said that, you'd think I was crazy.

    I didn't re-write it because it's not clear what you expect. You want FULL if the field contains either of those words, and OTHER if it doesn't? Or you want FULL if it's FULL SERVICE and OTHER if it's LIMITED ACCESS. I think it is the former though. Anyway, you should be able to fix it by repeating the field reference.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,555
    You need to repeat the test
    Code:
    Expr1: IIf([dbo_vw_ReportingInfo]![Location Type]="FULL SERVICE" Or [dbo_vw_ReportingInfo]![Location Type]= "LIMITED ACCESS","FULL","OTHER")
    Might be able to use IN()

    Code:
    Expr1: IIf([dbo_vw_ReportingInfo]![Location Type] IN ("FULL SERVICE", "LIMITED ACCESS"),"FULL","OTHER")
    
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    anoble1 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    7
    The first one worked great! Thanks for the help. That crossed my mind, but I didn't think it would matter.

    Quote Originally Posted by Gicu View Post
    Try these:
    Code:
    IIf([dbo_vw_ReportingInfo]![Location Type]="FULL SERVICE" Or [dbo_vw_ReportingInfo]![Location Type]= "LIMITED ACCESS","FULL","OTHER")
    Code:
    IIf([dbo_vw_ReportingInfo]![Location Type] IN ("FULL SERVICE","LIMITED ACCESS"),"FULL","OTHER")
    Cheers,

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,555
    Well, it wouldn't hurt to try?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

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

Similar Threads

  1. Replies: 5
    Last Post: 11-01-2021, 08:09 AM
  2. Replies: 11
    Last Post: 04-29-2015, 01:38 PM
  3. if statement in sql statement, query builder
    By 54.69.6d.20 in forum Access
    Replies: 4
    Last Post: 09-11-2012, 07:38 AM
  4. Replies: 7
    Last Post: 08-17-2011, 01:49 PM
  5. multiple iif statement NEED HELP PLZ
    By scott munkirs in forum Reports
    Replies: 1
    Last Post: 09-27-2006, 05:21 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