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

    VBA code to open Multiple records stored in the Attachment field by clicking ID field

    Hi Every one

    I have a table named Table1 and it has two fields 'ID' and an 'Files' (Attachment field with multiple records). I made a query By draging the ID and File name component of the attachment field. My form is based on That query. Now I have 2 fields on the form .The 'ID' field and 'Table1.Files.FileName' . I renamed the 'Table1.Files.FileName' to
    'tbxFileName' and on the forms ID's on click event I have theis code Igot from this forum

    This is the code window

    Option Compare Database
    Private Sub ID_Click()
    Dim strFilePath
    With Me.RecordsetClone
    .Bookmark = Me.Bookmark


    strFilePath = "C:\Temp\" & Me.tbxFileName
    If Dir(strFilePath) <> "" Then VBA.Kill strFilePath
    ![Table1.MyDocs.FileData].SaveToFile strFilePath
    VBA.Shell "Explorer.exe " & Chr(34) & strFilePath & Chr(34), vbNormalFocus
    End With
    End Sub

    when i click the id i get runtime error
    'Item not found in this collection'
    and this line in the code window is yellow '![Table1.MyDocs.FileData].SaveToFile strFilePath'

    Can some one please help me to work this out especialy by 'Super Moderator' who made the code
    I would apreciate any help
    Thank you

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Did you already create a folder named Temp at the C: root level?
    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
    aspen is offline Competent Performer
    Windows Vista Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    127
    hi
    Thanks for coming back. actually no I have not. I didn't know I had to. But noy I have created a folder called 'Temp' By clicking My computer -Local disc c and in c drive i created this a new
    folder called temp. root level is does it mean that the path shold mach? When i open the folder and check the path it matches with the path in the code . but still i get the error. If i past the file in the folder and run the code the file gets deleted. so i think the folder is ok!.
    Thank you
    Last edited by aspen; 04-13-2012 at 09:55 AM.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    The code worked for me when I posted it. Have you step debugged? If you want to provide your project, I will look at.
    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
    aspen is offline Competent Performer
    Windows Vista Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    127
    Thanks
    I tried to attach compressed and records deleted but i think the size is too big.
    Can you please attach a sample to this post
    Thank you

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

    Attach sample

    Here is the project
    please see it for me
    Thank yousample attach.zip

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    1. Edit the query to include the FileData element of the Attachment field.

    2. Change RecordSource of one of the textboxes to FileData or remove one. Don't need two textboxes bound to FileName

    3. Modify code to match your field name: ![Table1.Files.FileData].SaveToFile strFilePath
    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
    aspen is offline Competent Performer
    Windows Vista Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    127
    Thank you veryy much

    it should work now. l will let you know the progrss
    thank you for your contribution

    thank you

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

    May you live long enough to give this extra ordinary help to those in need
    It works and its wonderful
    Enjoy
    Thanks a million

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

Similar Threads

  1. Replies: 16
    Last Post: 04-11-2012, 10:56 AM
  2. Replies: 11
    Last Post: 09-27-2011, 07:19 AM
  3. Replies: 1
    Last Post: 08-11-2011, 11:33 AM
  4. Add multiple records with one field
    By Meccer in forum Forms
    Replies: 1
    Last Post: 01-05-2011, 12:19 PM
  5. Replies: 1
    Last Post: 12-10-2009, 08:41 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