Results 1 to 12 of 12
  1. #1
    LilMissAttack is offline Novice
    Windows XP Access 2007
    Join Date
    May 2010
    Posts
    26

    IIF statement in control source of text box

    Hi,



    I am trying to do a simple IIF in the control source of a text box but it is returning #Name?...can someone tell me what I am missing?

    =IIf([OutOfOffice]![StartDate]="8/1/2011",[OutOfOffice]![EmpName])

    Thanks!

  2. #2
    LilMissAttack is offline Novice
    Windows XP Access 2007
    Join Date
    May 2010
    Posts
    26
    I also tried
    =IIf([OutOfOffice]![StartDate]=#8/1/2011#,[OutOfOffice]![EmpName],"")

  3. #3
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,085
    Try taking out the [OutOfOffice]! I'm assuming that the report is based on a query/Table so you only need the field name.

  4. #4
    LillMcGill is offline Dagny fan
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2010
    Location
    Southern USA
    Posts
    70
    What is the name of the textbox?

  5. #5
    LilMissAttack is offline Novice
    Windows XP Access 2007
    Join Date
    May 2010
    Posts
    26
    Name of the text box is Text153.

    Actually now I've come up with this (still not working lol) because what I want it to do is if the date in the table = 8/1/2011, I want it to return the employees name - Reason for out of the office....

    =IIf([OutOfOffice]![StartDate]=#8/1/2011#,[OutOfOffice]![EmpName] & "-" & [OutOfOffice]![Reason])

    Am I correct using the # symbol around the date? I also tried quotes and that didn't work either....

  6. #6
    LillMcGill is offline Dagny fan
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2010
    Location
    Southern USA
    Posts
    70
    I agree with Ray... why do you need the [OutOfOffice]?

  7. #7
    LilMissAttack is offline Novice
    Windows XP Access 2007
    Join Date
    May 2010
    Posts
    26
    When I used the expression builder it put the table name in like that....I removed it but it still isn't working...

  8. #8
    LillMcGill is offline Dagny fan
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2010
    Location
    Southern USA
    Posts
    70
    Is the field StartDate in the table or query that is the record source for the report?

  9. #9
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,085
    What is the Table/Queryname the report is based on? What is in the Recordsource of the report?

  10. #10
    LilMissAttack is offline Novice
    Windows XP Access 2007
    Join Date
    May 2010
    Posts
    26
    That may have been part of the problem...I set it as the source, now I'm not getting the #Name? but instead it's just blank...

  11. #11
    LilMissAttack is offline Novice
    Windows XP Access 2007
    Join Date
    May 2010
    Posts
    26
    Yes the field StartDate is in the table I'm trying to pull from. I cannot figure out why this isn't working. It is now giving me the "Enter Parameters" box for the OutOfOffice table. I know this means something might be misspelled/missing/bad data, but I have double checked everything and no misspellings and everything is present.

  12. #12
    LilMissAttack is offline Novice
    Windows XP Access 2007
    Join Date
    May 2010
    Posts
    26
    I recreated this table/report on my home computer, also in Access 2007 and it worked?! Exact same data, everything...it worked on my home computer but not my work computer.

    However, it only returned one record, the first one in the table that had the date I was trying to pull. How do I get this to pull multiple records? There are more records with that date in the table.

    Thanks!

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

Similar Threads

  1. control source
    By nashr1928 in forum Forms
    Replies: 5
    Last Post: 03-12-2011, 09:31 PM
  2. Control Source
    By sarah54 in forum Access
    Replies: 1
    Last Post: 03-07-2011, 09:00 PM
  3. Control Source for Text Box (#error)
    By km8415 in forum Forms
    Replies: 3
    Last Post: 06-27-2010, 10:45 AM
  4. Replies: 1
    Last Post: 04-29-2010, 05:15 PM
  5. Replies: 2
    Last Post: 07-30-2009, 08:02 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