If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
list attachments in a form or record
I have figured out how to add attachments to a record, but the default way of
handling them on forms isn't the greatest. I would like to be able to have a list of the attachments directly on a form (I have a form that lists details for contacts and I would like one of the fields to be the list of attachments). I would also like the ability to select and open the attachments from the form. Is this possible? I did a quick search and haven't found any discussion that covers this. I'm using Access 2007. |
#2
|
|||
|
|||
list attachments in a form or record
First I would question that maybe you shouldn't store the documents in the
database in an attachment field? Don't want your database growing too much etc.... You could use a table which is related to your main record and store the paths and shell to view the files themselves. If you want to use an attachment field you can use code to cycle through the attachments and display them how you like. Here's some code that loops through an Attachment field and actually save the files. You just need a small portion of this to loop through and grab the "filename" for each attachment in the ONE attachments field. 'Open recordset of attachments, save each one to disk and assign to attachments() array For iii = 1 To 9 Attachments(iii) = "" Next iii filepath = CurrentDBDir() & "Attachments999\" If Len(Dir(filepath, vbDirectory)) = 0 Then MkDir filepath End If iii = 1 Set RSAttachments = rs.Fields("Attachments").Value While Not RSAttachments.EOF If (FileExists(filepath & RSAttachments.Fields("FileName").Value)) Then Kill filepath & RSAttachments.Fields("FileName").Value End If RSAttachments.Fields("FileData").SaveToFile filepath Attachments(iii) = filepath & RSAttachments.Fields("FileName").Value iii = iii + 1 RSAttachments.MoveNext Wend RSAttachments.Close Hope that gets you started. I just wrote some code for dealing with an unlimited number of files and folder associated with accounts and contacts. Email me if you want to see that code/approach. This code on MSDN will also help (if you stay with the attachment approach) http://msdn.microsoft.com/en-us/library/bb258184.aspx HTH, -- Mark Andrews RPT Software http://www.rptsoftware.com http://www.donationmanagementsoftware.com 1. "Gntlhnds" wrote in message ... I have figured out how to add attachments to a record, but the default way of handling them on forms isn't the greatest. I would like to be able to have a list of the attachments directly on a form (I have a form that lists details for contacts and I would like one of the fields to be the list of attachments). I would also like the ability to select and open the attachments from the form. Is this possible? I did a quick search and haven't found any discussion that covers this. I'm using Access 2007. |
#3
|
|||
|
|||
list attachments in a form or record
I thank you for your help. I was under the impression that when Access lists
the files in its default Attachments field, it's actually listing just a "shortcut" if you will to the files, not actually storing the files in the database. That is all I need, really. Because they are PDF files, I don't want them to be stored in the actual database. I just want a list of the file names to appear on the form with the ability to double-click on the file name and open the file. "Mark Andrews" wrote: First I would question that maybe you shouldn't store the documents in the database in an attachment field? Don't want your database growing too much etc.... You could use a table which is related to your main record and store the paths and shell to view the files themselves. If you want to use an attachment field you can use code to cycle through the attachments and display them how you like. Here's some code that loops through an Attachment field and actually save the files. You just need a small portion of this to loop through and grab the "filename" for each attachment in the ONE attachments field. 'Open recordset of attachments, save each one to disk and assign to attachments() array For iii = 1 To 9 Attachments(iii) = "" Next iii filepath = CurrentDBDir() & "Attachments999\" If Len(Dir(filepath, vbDirectory)) = 0 Then MkDir filepath End If iii = 1 Set RSAttachments = rs.Fields("Attachments").Value While Not RSAttachments.EOF If (FileExists(filepath & RSAttachments.Fields("FileName").Value)) Then Kill filepath & RSAttachments.Fields("FileName").Value End If RSAttachments.Fields("FileData").SaveToFile filepath Attachments(iii) = filepath & RSAttachments.Fields("FileName").Value iii = iii + 1 RSAttachments.MoveNext Wend RSAttachments.Close Hope that gets you started. I just wrote some code for dealing with an unlimited number of files and folder associated with accounts and contacts. Email me if you want to see that code/approach. This code on MSDN will also help (if you stay with the attachment approach) http://msdn.microsoft.com/en-us/library/bb258184.aspx HTH, -- Mark Andrews RPT Software http://www.rptsoftware.com http://www.donationmanagementsoftware.com 1. "Gntlhnds" wrote in message ... I have figured out how to add attachments to a record, but the default way of handling them on forms isn't the greatest. I would like to be able to have a list of the attachments directly on a form (I have a form that lists details for contacts and I would like one of the fields to be the list of attachments). I would also like the ability to select and open the attachments from the form. Is this possible? I did a quick search and haven't found any discussion that covers this. I'm using Access 2007. . |
#4
|
|||
|
|||
list attachments in a form or record
send me an email and I'll give you the code I used. See website for contact
info. -- Mark Andrews RPT Software http://www.rptsoftware.com http://www.donationmanagementsoftware.com "Gntlhnds" wrote in message ... I thank you for your help. I was under the impression that when Access lists the files in its default Attachments field, it's actually listing just a "shortcut" if you will to the files, not actually storing the files in the database. That is all I need, really. Because they are PDF files, I don't want them to be stored in the actual database. I just want a list of the file names to appear on the form with the ability to double-click on the file name and open the file. "Mark Andrews" wrote: First I would question that maybe you shouldn't store the documents in the database in an attachment field? Don't want your database growing too much etc.... You could use a table which is related to your main record and store the paths and shell to view the files themselves. If you want to use an attachment field you can use code to cycle through the attachments and display them how you like. Here's some code that loops through an Attachment field and actually save the files. You just need a small portion of this to loop through and grab the "filename" for each attachment in the ONE attachments field. 'Open recordset of attachments, save each one to disk and assign to attachments() array For iii = 1 To 9 Attachments(iii) = "" Next iii filepath = CurrentDBDir() & "Attachments999\" If Len(Dir(filepath, vbDirectory)) = 0 Then MkDir filepath End If iii = 1 Set RSAttachments = rs.Fields("Attachments").Value While Not RSAttachments.EOF If (FileExists(filepath & RSAttachments.Fields("FileName").Value)) Then Kill filepath & RSAttachments.Fields("FileName").Value End If RSAttachments.Fields("FileData").SaveToFile filepath Attachments(iii) = filepath & RSAttachments.Fields("FileName").Value iii = iii + 1 RSAttachments.MoveNext Wend RSAttachments.Close Hope that gets you started. I just wrote some code for dealing with an unlimited number of files and folder associated with accounts and contacts. Email me if you want to see that code/approach. This code on MSDN will also help (if you stay with the attachment approach) http://msdn.microsoft.com/en-us/library/bb258184.aspx HTH, -- Mark Andrews RPT Software http://www.rptsoftware.com http://www.donationmanagementsoftware.com 1. "Gntlhnds" wrote in message ... I have figured out how to add attachments to a record, but the default way of handling them on forms isn't the greatest. I would like to be able to have a list of the attachments directly on a form (I have a form that lists details for contacts and I would like one of the fields to be the list of attachments). I would also like the ability to select and open the attachments from the form. Is this possible? I did a quick search and haven't found any discussion that covers this. I'm using Access 2007. . |
Thread Tools | |
Display Modes | |
|
|