Results 1 to 14 of 14
  1. #1
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276

    IIF statement for attachments

    I am having problem setting up a querry with IIF statement.



    I have made a querry which shows if there are attachments in table.
    if there is an attachment it shows (something like) @(1) and if there is no attachment it shows @(0) in querry filed.

    what i am trying to do is, if there is an attachment it should say "YES" and If there is no attachment it should say "NO"

    for which I have tried the following formulas in querry but its none are working.

    TEST: IIf([purattach] Is Null,"YES","NO")
    TEST: IIf([purattach.FileData] Is Null,"YES","NO")
    TEST: IIf([purattach.FileName] Is Null,"YES","NO")
    TEST: IIf([purattach.FileType] Is Null,"YES","NO")


    Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,619
    What do you mean by not working - error message, wrong results, no results?
    By your narrative of what you want, you have the "Yes" and "No" backwards.
    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.

  3. #3
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    afteryour reply i tested the following to get the error message.

    TEST: IIf([purattach] Is Null,"NO","YES")


    ERROR MESSAGE:

    The expression you entered has an invalid . (dot) or ! operator or invalid parentheses.

    You may have enteredan invalid identifier or typed parentheses following the null constant

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,619
    I tested Is Null and it failed but this worked:
    IIf(IsNull([purattach]), "No", "Yes")
    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
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    I tried the following in querry
    Expr1: IIf(IsNull([purattach]),"No","Yes")
    and am getting the following error message.

    The multi-valued field '[purattach]' is not valid in the expression 'Expr1: IIf(IsNull([purattach]),"No","Yes")'.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,619
    Crud! Multi-value fields, don't like 'em, never use 'em.

    I should have guessed from the name this would be an Attachment datatype. I've never used this field type.

    If this doesn't work, I have nothing else:
    IIf([purattach]="", "No","Yes")
    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.

  7. #7
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254

    aamer -

    Like, June7, I do not use attachment fields. Therefore, this is just an idea. However, since all else has failed, at this point, you may want to try:

    IIF(Len([purattach])>0,"Yes","No")

    All the best,

    Jim

  8. #8
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    For multi-valued fields:

    Expr1: IIf(IsNull([purattach].Value),"No","Yes")

  9. #9
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    In fact, this is a good reference for those:
    http://office.microsoft.com/en-us/ac...33722.aspx#BM7

  10. #10
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    none are working for me

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,619
    Read this article http://www.techrepublic.com/blog/mso...-20072010/5134

    SELECT ID, purattach.Value, IIf(IsNull([purattch].[Value]),"No","Yes") AS Condition FROM Table1;

    SELECT ID, purattach.Value FROM Table1 WHERE ((Not (purattach.Value) Is Null));

    This works for text datatype where data has been entered by multi-value enabled combobox or listbox.

    For attachment datatype use FileData or FileName or FileType instead of Value.
    Last edited by June7; 06-24-2011 at 10:58 AM.
    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
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    thank you june for pointing me in the right direction.
    thank u boblarson for your IIF statement i used but with the modification june poined out.

    I used the following and it worked like a charm
    Expr1: IIf(IsNull([purattach].[FileData]),"No","Yes")

  13. #13
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Quote Originally Posted by June7 View Post
    For attachment datatype use FileData or FileName or FileType instead of Value.
    I missed that it was an attachment (even though it was clearly stated in the title).


  14. #14
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    thats ok, still with your help i was able to fix it

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

Similar Threads

  1. Save Attachments.
    By drunkinmunki in forum Programming
    Replies: 6
    Last Post: 11-20-2012, 10:11 AM
  2. Attachments in Report
    By Meccer in forum Reports
    Replies: 1
    Last Post: 04-15-2011, 01:37 PM
  3. Unique attachments
    By twalishuka in forum Programming
    Replies: 1
    Last Post: 02-28-2011, 09:28 AM
  4. Attachments
    By cjp78 in forum Access
    Replies: 4
    Last Post: 05-11-2010, 07:30 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