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!
4 1945
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. -
Private Sub btnPgeAttachFile_Click()
-
On Error GoTo command7_error
-
-
-
-
Dim vrtSelectedItem As Variant
-
Dim strMyDir As String
-
Dim strFilename As String
-
Dim strNewpath As String
-
Dim strReportNumber As String
-
-
-
Set dlgOpen = Application.FileDialog(msoFileDialogFilePicker)
-
Set fs = CreateObject("Scripting.FileSystemObject")
-
-
strCurrentPath = CurrentProject.Path & "\attachments"
-
strReportNumber = Me.txtCaseNumber.Value
-
-
-
If Dir(strCurrentPath, vbDirectory) = "" Then
-
MsgBox "The Attachments folder cannot be located", vbCritical, "ERROR"
-
GoTo command7_exit
-
-
End If
-
-
-
With dlgOpen
-
-
.Title = "Attatch File"
-
.AllowMultiSelect = True
-
If .Show = True Then
-
For Each vrtSelectedItem In .SelectedItems
-
strMyDir = vrtSelectedItem
-
-
'this function grabs the file name of the selected file
-
-
strFilename = Right(strMyDir, Len(strMyDir) - InStrRev(strMyDir, "\"))
-
strNewpath = strCurrentPath & "\" & strReportNumber
-
If Not fs.folderexists(strNewpath) Then
-
fs.createfolder strNewpath
-
End If
-
-
fs.CopyFile strMyDir, strNewpath & "\"
-
strSQL = "insert into tblAttachments(attachment,attach,casenumber) values ('" & strNewpath & "\" & strFilename & "','" & strFilename & "'," & strReportNumber & ")"
-
DoCmd.RunSQL strSQL
-
Next vrtSelectedItem
-
Else
-
MsgBox "You clicked Cancel"
-
End If
-
End With
-
-
command7_exit:
-
Set fs = Nothing
-
Set dlgOpen = Nothing
-
-
Me.lstPgeAttachAttachment.Requery
-
-
Exit Sub
-
-
-
command7_error:
-
MsgBox Err.Description
-
Resume command7_exit
-
-
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
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
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: yabba |
last post by:
w2k server... after rebooting the event viewer/application log shows multiple
restarts of Active Server Pages and they continue to build in memory as each
start produces a IWAM_SERVERNAME in the...
|
by: Ohaya |
last post by:
Hi,
I'm trying to understand a situation where ASP seems to be "blocking" of
"queuing" requests. This is on a Win2K Advanced Server, with IIS5.
I've seen some posts (e.g.,...
|
by: Mike |
last post by:
Looking to find any information on how to properly configure multiple
instances of DB2. This is on Win2k db2 ver 7.2. I am basically looking
for information on how the multiple instance settings...
|
by: Steve Mauldin |
last post by:
I have three websites that were developed by using the same code in .net.
They are all located under wwwroot on my desktop running windows 2000
pro.because Windows 2000 pro only supports a single...
|
by: vze1r2ht |
last post by:
I have many types of classes and I'm deciding whether to use a single
class or multiple classes for EACH type of class.
For an example:
User class has 3 classes associated with it:
User...
|
by: Claudio Pacciarini |
last post by:
Hi everyone,
I have a question about .NET code sharing and reuse, and also about
application design best practices / guidelines.
Currently, we have many different .NET projects in source...
|
by: Al Christoph |
last post by:
I posted this last week end in the MSDN forums. No luck there. Let's see what
the experts here have to say:-))))
I have a rather convoluted project. The distributable will come in eight...
|
by: keerthyragavendran |
last post by:
hi
i'm downloading a single file using multiple threads...
how can i specify a particular range of bytes alone from a single
large file... for example say if i need only bytes ranging from...
|
by: =?Utf-8?B?bGpsZXZlbmQy?= |
last post by:
I have a situation where I need to develop on two different computers. My
solution is to simply save the project on a USB flash drive. Everything
seems to work, except that the files that were...
|
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= |
last post by:
I have created a class library (DLL) that requires a certain XML file in the
same directory as the DLL. This XML file is essentially a configuration or
settings file but I want it to be a separate...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |