By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,806 Members | 1,293 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,806 IT Pros & Developers. It's quick & easy.

Multiple File Manager

P: 10
I would like to add an "attachments" option to my form that will allow users to upload files (e.g. Word documents, Excel spreadsheets, etc.) to a shared folder. I do not want the files to be stored as OLE objects in the database, but rather I would like to access the files from my form as either absolute references or hyperlinks. In addition, the user may want to upload more than one file, in which case I will need the solution to dynamically add more than one link to the form.

This is similar to Adobe Acrobat where there is an "Attachments" tab on the left side of the form that allows the user to attach multiple files to the .pdf file.

Thank you!
May 21 '07 #1
Share this Question
Share on Google+
4 Replies

P: 19
I would like to add an "attachments" option to my form that will allow users to upload files (e.g. Word documents, Excel spreadsheets, etc.) to a shared folder. I do not want the files to be stored as OLE objects in the database, but rather I would like to access the files from my form as either absolute references or hyperlinks. In addition, the user may want to upload more than one file, in which case I will need the solution to dynamically add more than one link to the form.

This is similar to Adobe Acrobat where there is an "Attachments" tab on the left side of the form that allows the user to attach multiple files to the .pdf file.

Thank you!

Here is the code I wrote to add pictures for a certain record this will also do any files type all depends on what the computer has to be open the program. I hope htis helps. if you have any questions please let me know.


Expand|Select|Wrap|Line Numbers
  1. Private Sub btnPgeAttachFile_Click()
  2. On Error GoTo command7_error
  3.  
  4.  
  5.  
  6. Dim vrtSelectedItem As Variant
  7. Dim strMyDir As String
  8. Dim strFilename As String
  9. Dim strNewpath As String
  10. Dim strReportNumber As String
  11.  
  12.  
  13. Set dlgOpen = Application.FileDialog(msoFileDialogFilePicker)
  14. Set fs = CreateObject("Scripting.FileSystemObject")
  15.  
  16. strCurrentPath = CurrentProject.Path & "\attachments"
  17. strReportNumber = Me.txtCaseNumber.Value
  18.  
  19.  
  20. If Dir(strCurrentPath, vbDirectory) = "" Then
  21.     MsgBox "The Attachments folder cannot be located", vbCritical, "ERROR"
  22.     GoTo command7_exit
  23.  
  24. End If
  25.  
  26.  
  27. With dlgOpen
  28.  
  29.     .Title = "Attatch File"
  30.     .AllowMultiSelect = True
  31.     If .Show = True Then
  32.         For Each vrtSelectedItem In .SelectedItems
  33.         strMyDir = vrtSelectedItem
  34.  
  35.         'this function grabs the file name of the selected file
  36.  
  37.         strFilename = Right(strMyDir, Len(strMyDir) - InStrRev(strMyDir, "\"))
  38.         strNewpath = strCurrentPath & "\" & strReportNumber
  39.         If Not fs.folderexists(strNewpath) Then
  40.             fs.createfolder strNewpath
  41.         End If
  42.  
  43.         fs.CopyFile strMyDir, strNewpath & "\"
  44.         strSQL = "insert into tblAttachments(attachment,attach,casenumber)  values ('" & strNewpath & "\" & strFilename & "','" & strFilename & "'," & strReportNumber & ")"
  45.         DoCmd.RunSQL strSQL       
  46.         Next vrtSelectedItem
  47.     Else
  48.         MsgBox "You clicked Cancel"
  49.     End If
  50. End With
  51.  
  52. command7_exit:
  53. Set fs = Nothing
  54. Set dlgOpen = Nothing
  55.  
  56. Me.lstPgeAttachAttachment.Requery
  57.  
  58. Exit Sub
  59.  
  60.  
  61. command7_error:
  62. MsgBox Err.Description
  63. Resume command7_exit
  64.  
  65.  
then all you have to do is create a list of sorts on your form that will show the all the files that the certain record has on it. and have it follow the link based on what they need choose if you need that code as well i can post it too.

CG
May 21 '07 #2

P: 10
CG,

Thank you very much for the information and the quick response!

I am new to using Access, but I have used VBA extensively with Excel in the past, so I am starting to work through your code. It all seems fairly straight forward, but I want to make sure I understand the following line of code:

Me.lstPgeAttachAttachment.Requery

Does this line simply update the page titled "lstPgeAttachAttachment"?

Also, is there any way you can post a screenshot of your user query page?

Finally, would you mind posting the code for how to create a list of attachments on the form?

Thank you again!

Steve
May 21 '07 #3

P: 10
CG,

I was able to resolve my issue by using a combination of your script, and the scripts posted by ADezii at the following link:

http://www.thescripts.com/forum/thre...yperlinks.html

Thank you again for your help,

Steve
Jun 15 '07 #4

P: 19
CG,

I was able to resolve my issue by using a combination of your script, and the scripts posted by ADezii at the following link:

http://www.thescripts.com/forum/thre...yperlinks.html

Thank you again for your help,

Steve
sorry I was not able to get back to you and i am glad you got it working.
Jun 18 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.