Results 1 to 8 of 8
  1. #1
    timmygrover is offline Novice
    Windows Vista Access 2003
    Join Date
    Dec 2011
    Posts
    26

    IIF statement based on check box returns #error

    This is my statement:

    =IIf([Checkbox]=-1,"Yes","No")

    It works great once I've manipulated the checkbox, but before I touch it, it returns an #Error

    I don't know what value to assign in order to get a "no" if the check box hasn't been touched.



    I've also tried

    =IIf([Checkbox]=0 OR [Checkbox]="","No","Yes")

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Try

    =IIf([Checkbox]=0 OR IsNull([Checkbox]),"No","Yes")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    timmygrover is offline Novice
    Windows Vista Access 2003
    Join Date
    Dec 2011
    Posts
    26
    Same result

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    =Format([Checkbox],"Yes/No")


    Is the Checkbox bound or are you wanting to save the textbox value to table?
    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.

  5. #5
    timmygrover is offline Novice
    Windows Vista Access 2003
    Join Date
    Dec 2011
    Posts
    26
    No, I'm using this in an unbound table where the user fills out a few text boxes/check boxes/drop downs/etc., and then you get a certain string of text based on your input. The issue is that the checkboxes mess up my iif statements until I check/uncheck them. I can't find a way for them to function in a situation where they just need to be left unchecked.

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Did you mean 'unbound form' instead of 'table'?

    I tested my suggestion and it worked. Returns Yes, No, or empty string; no #Error.
    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.

  8. #8
    timmygrover is offline Novice
    Windows Vista Access 2003
    Join Date
    Dec 2011
    Posts
    26
    Yeah, June, i did mean form, and I was so busy responding to what I'm doing that i didn't try your solution! It worked! Thanks so much!

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

Similar Threads

  1. Replies: 5
    Last Post: 12-21-2011, 07:16 PM
  2. Dlookup in form returns #error
    By RickM in forum Access
    Replies: 1
    Last Post: 03-29-2010, 07:59 PM
  3. Replies: 3
    Last Post: 11-02-2009, 04:33 AM
  4. Replies: 4
    Last Post: 09-21-2009, 01:51 PM
  5. Query returns null..based on two tables
    By shsh_shah in forum Queries
    Replies: 1
    Last Post: 03-08-2009, 01:45 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