Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    MaineLady is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Aug 2014
    Posts
    46

    Question Iif function--- What am I doing wrong?


    I am trying to evaluate a field in an access database. I have entered iif([fieldx]="Contributor",1,0). The field that I am evaluating has the word Member or Contributor in it, but my formula always returns a zero (0). What am I doing wrong?

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    Some thoughts on things to check.
    1. Case sensitivity?
    2. Spacing before the word or after the word "Contributor?" Either in your IIF statement or in your records.
    3. Spelled correctly?

    What happens when you change up your query and set the criteria in Fieldx to =Contributor? Do you get only the records which contain the term Contributor?

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    What data type is Fieldx (is that the actual name)? Does it have a Lookup set in table? Why do you need to convert to 0 or 1?
    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.

  4. #4
    MaineLady is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Aug 2014
    Posts
    46
    The actual field name is Status, and yes it has a lookup table... person entering data can choose either Member or Contributor. I will be using the value set to determine what happens in another field.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Still don't know why you need to convert to 0 and 1.

    I NEVER set lookup in table. Show the RowSource sql of the lookup. Does it include an ID field? If so, I suspect the actual value of the field is the ID, not the descriptive text and that's why the expression fails.
    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.

  6. #6
    MaineLady is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Aug 2014
    Posts
    46
    OK... So I inserted another field and did not use the lookup table and now the function works. Now I want to delete the old field, but it tells me that I have to delete the relationship between the old field and the lookup table. When I do that, and I try to reopen my table, I get told that the object can't be found.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Did you change the Lookup setting from combobox to textbox?
    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
    MaineLady is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Aug 2014
    Posts
    46
    I am brand new at some of this sophisticated ACCESS stuff... I didn't change anything in the lookup setting... I created a new field that did not use a lookup table to fill it. When I used the iif function on that field it worked fine. Now I want to delete the field that did have the lookup and I am having a problem doing that.

    I guess what I really need to do is sign up for an Access class somewhere.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Change the lookup property on the old field from combobox to textbox. Try saving the revised table. Then try deleting the old field.

    Do you have relationship set in Relationships window using the old field?
    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.

  10. #10
    MaineLady is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Aug 2014
    Posts
    46
    I changed lookup property to textbox... If I try to delete the field, I'm told that I first have to delete the relationship to the table that has the lookup choices in it. I did that twice already... but when I tried to reopen my main database, I got told that the object couldn't be found... both times... Thank God for Carbonite back ups... I've made several other modifications to the database this afternoon, and I really don't want to lose it again.

    BTW... Thank you for your help. Sorry I'm such a dummy.

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I don't know why that field is being such a bugger. Could have been corrupted. If there is no relationship in the Relationship window and the lookup is removed (really, that should not even be necessary), and the field is not used anywhere else, then the field should be able to delete.
    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.

  12. #12
    MaineLady is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Aug 2014
    Posts
    46
    Right now the field has no entries in it. If I put the cursor in that field, it no longer shows the dropdown arrow. If I look at relationships, there is still a relationship between the table that had the lookup values in it and that field. If I click on that table and select DELETE, it tells me that the relationship has to be deleted first and asks if I want to delete the relationship and continue. I'm afraid to say YES because when I did that twice before, I ran into the "can't find the object" issue...

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Don't click on the table in Relationships, click on the line that connects the tables to delete the relationship between the fields.
    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.

  14. #14
    MaineLady is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Aug 2014
    Posts
    46
    To suppress my fear of losing the database again, I saved a copy to my desktop. I then deleted the table that had the lookup values in it... That process deleted the relationship between the field and the table. I was then able to delete the old field.

    Thank you so much for your help.... and for being so patient with my level of experience.

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Just glad you got a solution.
    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.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. what is wrong
    By Dinoshop in forum Access
    Replies: 1
    Last Post: 07-11-2014, 06:22 AM
  2. Replies: 3
    Last Post: 02-12-2014, 03:36 PM
  3. Replies: 8
    Last Post: 01-31-2014, 01:45 PM
  4. What's wrong!
    By khalid in forum Programming
    Replies: 15
    Last Post: 06-27-2011, 06:38 AM
  5. What is wrong with this IFF?
    By bburton in forum Reports
    Replies: 2
    Last Post: 03-16-2011, 10:42 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