473,383 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Using VBA to save an attachment to shared drive via Access 2010 forms

In an effort to digitize our personnel files, I am currently building an Access database that tracks stores employee information, to include admin documents, leave requests, training docs etc. After attending an Advanced Access user class, I discovered that Access databases are limited to 2GB.
Because each document must be uploaded, loading them into the database will not be sustainable using the attachment feature in Access 2010.
My goal is to make the previously created forms that had been built to save the attachments within the Tables now save to a shared drive and create a hyperlink to those stored files within the table using VBA. I'm a Novice with VBA but have slowly started picking it up.
An example of the fields existing in my Admin Document Upload Form "AdminDocUploadfrm" are:

Employee- combo box
Document Description- combo box
Doc Date - Date
Doc Upload - Attachment
Submit - button

My intent is for the VBA programming behind the "Submit Button" to format the save name of the doc by combining the Doc Date+Employee name+DocDescription, save it to a designated location on the shared drive and create a hyperlink in the Access table. And complicating things further, the file format is PDF for all saved docs (Although I don't think I'll need to open the PDF's within Access.

Any help in where to start on this or where I can find some source code to start is appreciated. Thanks.
Mar 13 '13 #1
2 7205
zmbd
5,501 Expert Mod 4TB
We all feel your pain here!
Even if you were using a "mature" RDMS in the long run, storing large amounts of data would become a headache and eventually lead to data corruption that you couldn't easily recover from.

The search on this site is a tad difficult at times; however, you should do one on hyperlinks, go to the bottom of this page and click on the VBA Insights Sitemap, look at article #26 and #88 as that could save you some time fetching the file paths. In fact, you might just spend some time scoping out that entire list.

As for the actual code.... please understand that we can help you with specific problems (one question per thread please) as you encounter them.
Mar 13 '13 #2
Actually found some code and customized it a bit to work. Still looking for an answer on the best way to automate the generation of a hyperlink to the filename so I can touch the file from Reports or querries.
Expand|Select|Wrap|Line Numbers
  1. Private Sub AdminDocPath_DblClick(Cancel As Integer)
  2. Dim fd As FileDialog
  3. Set fd = Application.FileDialog(msoFileDialogFilePicker)
  4. 'the number of the button chosen
  5. Dim FileChosen As Integer
  6. FileChosen = fd.Show
  7. '1) To set the caption of the dialog box,
  8. ' set the Title property
  9. fd.Title = "Select Admin Document to Upload"
  10. '2) Set the oddly named InitialFileName property to
  11. ' determine the initial folder selected
  12. fd.InitialFileName = "C:\Users\....."
  13. '3) Set the InitialView property to control how your files
  14. ' appear on screen (as a list, icons, etc.)
  15. fd.InitialView = msoFileDialogViewSmallIcons
  16. '4) To set the filters (you can have as many as you like)
  17. ' first clear any existing ones, then add them one by one
  18. fd.Filters.Clear
  19. fd.Filters.Add "PDF macros", "*.pdf"
  20. fd.Filters.Add "Excel macros", "*.xlsm"
  21. ' if there's more than one filter, you can control which
  22. ' one is selected by default
  23. fd.FilterIndex = 1
  24. ' if there's more than one filter, you can control which
  25. ' one is selected by default
  26. fd.FilterIndex = 1
  27. '5) Set the ButtonName property to control the text on
  28. ' the OK button (the ampersand means the following
  29. ' letter is underlined and choosable with the ALT key)
  30. fd.ButtonName = "Choose PDF file"
  31. If FileChosen <> -1 Then
  32. 'didn't choose anything (clicked on CANCEL)
  33. MsgBox "Upload Cancelled"
  34. Else
  35. 'display name and path of file chosen
  36. MsgBox fd.SelectedItems(1)
  37. End If
  38. 'store the selected file to a variable
  39. strSelectedFile = fd.SelectedItems(1)
  40. 'parse out the filename from the path
  41. strFilename = Right(strSelectedFile, Len(strSelectedFile) - InStrRev(strSelectedFile, "\"))
  42. 'build the destination
  43. strDestination = "C:\Users\....." & strFilename
  44. 'copy the file to the new folder
  45. FileCopy strSelectedFile, strDestination
  46. 'store file as part of the record
  47. Me.AdminDocPath = strFilename
  48. End Sub
Apr 4 '13 #3

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

Similar topics

13
by: Rodrigue | last post by:
I as a developer have an application that I can run from my box or from a shared drive, but I cannot get anybody else to run it. They do have the same version of the framework on their boxes, yet...
1
by: clusardi2k | last post by:
Hello, I have a shared drive on SGI, Linux, and Windows. The fact that I'm using a shared drive may be mute information. The problem is within the same program a second call to fopen does not...
11
by: Brett | last post by:
I have an assembly on a shared LAN drive. On my developer machine, I give that assembly full trust from the .NET wizard. It works fine. I go to a user machine on the LAN, map to the shared...
0
by: JeffW | last post by:
Researched this, but none of the proposed solutions are working for me. Am hoping for some insight. Am trying to open a binary file that exists on a shared drive for reading. Code lives inside...
3
by: c_shah | last post by:
I am having a .NET Application. Install the application on a Share drive on the network. Any user WHO's machine is connected to network can access the application by clicking on short cut on his...
13
by: Pamela via AccessMonster.com | last post by:
Hi All; I work for a company which is currently utlizing MS Access on a shared drive where people from all over the country access. Because all are wishing to view a single database maintained...
3
by: fullyleaded | last post by:
hello all and a big pre-thanks for help. I am developing a simple message taking app that i would like anyone in the office to access. my intention is to put icons on their desktops which will...
0
by: =?Utf-8?B?SmltSGVhdmV5?= | last post by:
I developed some web pages and stored those pages on a "removable drive". All was right with the world. I then took the "removable drive" and moved it to another machine but mapped that drive with...
0
by: erniemack | last post by:
Using comdlg32.dll to allow the user to reference a .jpg or .bmp file I want to have the default search to be the current folder plus \images. How can I pass that info to comdlg32.dll?
1
by: Alan Yim | last post by:
Hi folks, My company recently upgraded our Office suite from 2003 to 2010. The problem in particular is with an Access database that was originally designed in Access 2003. The code in question...
0
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.