Results 1 to 6 of 6

IIf true result- more than one field?

  1. #1
    Budatlitho is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Mar 2016
    Posts
    5

    IIf true result- more than one field?

    Hello:
    I am trying to get two database fields to display when the IIF statement is true.
    Here's what I have.
    =IIf((Left([guests1],1)<>" "),[guests1],"") , which gives [guest1] field value when [guest1] is not equal to " "
    What I need to do is combine another field, [name] so that I get [name] & [guests1] when [guest1] is not equal to " "
    TIA

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,402
    =IIf((Left([guests1],1)<>" "),[Name] & " - " & [guests1],null)

    though I would suggest staying away from reserved names like... NAME, DATE, TIME


  3. #3
    Budatlitho is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Mar 2016
    Posts
    5
    Tried your solution, here is output:
    guestsrpt1 - Mary Lou Johnstone

    guestsrpt1 is query name

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,402
    that's the problem with using reserved words :P

    insert your actual field name where you see [NAME] in my statement, if your actual field name is NAME then I suggest you change it or you will constantly have to make sure you're enclosing the field name in square brackets []

  5. #5
    Budatlitho is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Mar 2016
    Posts
    5
    Can the field be referenced with an explicit name, ie: [tablename].[fieldname] in the IIF statement?

  6. #6
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,402
    yes it can

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

Similar Threads

  1. Display field if condition is true
    By Ganga983 in forum Queries
    Replies: 1
    Last Post: 03-23-2019, 12:17 PM
  2. Change result if condition is true
    By rfigueroa1976 in forum Access
    Replies: 9
    Last Post: 09-07-2018, 01:52 PM
  3. On Field Change, Visible = True
    By wtucker in forum Access
    Replies: 20
    Last Post: 04-25-2018, 12:11 PM
  4. Replies: 3
    Last Post: 04-18-2017, 07:45 AM
  5. Replies: 7
    Last Post: 01-11-2012, 12:24 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
  •  
Tech Forums: Microsoft Office Forums