Results 1 to 7 of 7
  1. #1
    zburns is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    39

    IIF Expression from two fields

    I have two yes/no fields [office] and [operator] in a query and would like to reference result in another field used for report.
    Rather than show -1 or 0 need to show 'office' or 'operator'. I think this could also be done with unbound control in report but don't know how to construct.
    Any help is greatly appreciated.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    You can place your expression directly in an unbound control or in the OnFormat event of the Report's Module.

  3. #3
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 64bit Access 2013
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    In a new table, two fields, first one contains -1 and 0, second one contains Office and Operator. Join to your table containing Yes/No field. Use field from new table that displays Office and Operator in your query and not the Yes/No field from your original table.

  4. #4
    InsuranceGuy is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Location
    Colorado
    Posts
    126
    Quote Originally Posted by zburns View Post
    I have two yes/no fields [office] and [operator] in a query and would like to reference result in another field used for report.
    Rather than show -1 or 0 need to show 'office' or 'operator'. I think this could also be done with unbound control in report but don't know how to construct.
    Any help is greatly appreciated.
    Fairly difficult to follow what you're attempting, but I think you're looking for an IIF statement on a text box on your report or in your query.

    Try:
    Code:
    =IIF([Office],"Office","Not Office")
    Be aware that -1 = True, 0 = False in Access.
    Therefor, this returns "Office" when [Office]=-1 and returns "Not Office" when [Office]=0.

    Jeff

  5. #5
    zburns is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    39
    my query has one yes/no field named [A] and another yes/no field names [B]. Would like another field with expression checking value of [A] and [B]. If [A] = -1 then display 'office'. If [B] = -1 display 'operator'. record will only show one or the other. If fields = 0 or is null then leave blank. Sooo .. every record will either be blank or office or operator.
    Sorry if it is still confusing. I'm thinking I could also have an unbound control on report with the expression as well?

  6. #6
    InsuranceGuy is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Location
    Colorado
    Posts
    126
    That clarifies a lot actually. Here you go:

    Code:
    =IIF([A],"office",IIF([B],"operator",null))

  7. #7
    zburns is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    39
    Thanks, worked fine. Just what I was needing.
    Sorry I wasn't more clear in what I was needing.

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

Similar Threads

  1. calculation fields by using lookup expression
    By Mony in forum Programming
    Replies: 3
    Last Post: 04-03-2015, 04:48 PM
  2. Replies: 1
    Last Post: 06-27-2013, 09:33 AM
  3. Replies: 16
    Last Post: 12-08-2012, 07:44 AM
  4. Replies: 2
    Last Post: 11-20-2012, 03:21 AM
  5. Replies: 2
    Last Post: 05-05-2011, 12:41 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