Results 1 to 4 of 4
  1. #1
    aspen is offline Competent Performer
    Windows Vista Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    127

    how to refer to if attachment count is zero vba

    good day

    I have a form (Datasheet view) based on a table "Table1". I frequently moove attachments from one record to another and as a result some of the records in the table has zero attachments (no attachment). what i am trying to do is have a code or macro on the after update event of the form to delet the record if the attachment field is null or zero .
    my attachment field name is 'Files'. I have tried various tqunique to refer to attacment field. like if is null, is null, count zero. I think its a bit defferent than a normal field.
    can some one please help me in writing the code " if field name 'files' attachment count is zero do comand delet record". I searched google and very few examples were there
    but non worked.

    please help


    thank you

  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
    I haven't needed this (don't use the attachment data type), but a quick Google found this:

    http://stackoverflow.com/questions/7...crosoft-access
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    aspen is offline Competent Performer
    Windows Vista Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    127
    Thanks pbaldy

    if we use this coding for a text field it works but not for attachment daata type
    If (IsNull(.Files)) Then
    DoCmd.RunCommand acCmdDeleteRecord
    is there a defferent way to refer to attachment data type
    I cheched the link but i couldnt understand the second part PART 2 - Use the custom function in your Access query. I have never done anything like that in a query. I pasted that coding in sql window of the query "SELECT Table1.ID, AttachmentCount("Table1","MyAttach","[ID]=" & [ID]) AS [Num Attach]
    FROM Table1;" . It created a field inthe query "Num Attach: AttachmentCount("Table1","MyAttach","[ID]=" & [ID])". In datasheet view it showed a "0" in each field. But my table had attachments in some fields.
    What do you think i am doing wrong

    Thank you

  4. #4
    aspen is offline Competent Performer
    Windows Vista Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    127
    Dear pbaldy

    Thank you so much. I got it working. I did some mistake may be. Now i have the record set count right so maybe i can make a delet query some thing.
    Thank you very much for the for the quick response.

    have a good day

    thank you
    Last edited by aspen; 05-05-2012 at 11:43 AM.

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

Similar Threads

  1. Replies: 16
    Last Post: 04-30-2012, 07:12 AM
  2. Replies: 4
    Last Post: 02-16-2012, 05:23 PM
  3. Refer to ONLY THE MONTH??
    By taimysho0 in forum Programming
    Replies: 18
    Last Post: 01-27-2012, 01:12 PM
  4. Replies: 1
    Last Post: 04-15-2011, 01:43 PM
  5. Refer to main form
    By terryvanduzee in forum Forms
    Replies: 3
    Last Post: 10-23-2009, 07: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