Select a file listed in a list box and push a button and have the file automatically be attached to the attachment field in an Access 2010 database
Posted on 2013-01-08
History of situation
I have an access 2010 database that part of it's use it to manage drawings that get sent to us for fabrication. These drawings get dropped into many different directories that then need to be checked periodically throughout the day to see if there are any new ones. Needless to say this is quite time consuming and prone to error. So, I've created a form that will with the push of a button pull in the path and fill name of all the files in each directory into a table and then compare against the previous import. The new, non-matching drawing files get listed in a list box. From there we can select each new drawing file listed and precede with each of our remaining actions.
I tell you all of that so you will understand where I am and now what it is I want to be able to do. One of the actions I would like to perform is when I select on one of the files listed in the list box I would then like to push a button that would activate the code behind it that would take the information in the file name field and file path fields and using VBA be able to automatically attach the selected drawing file to the attachment field.
I have attached a screen shot of what this part of the form looks like. You will see a drawing file highlighted and the button I will click to be able to view the file based on the linked path stored in the table. During the time that file is opening I would also like the original file to be automatically linked, or just the information updated to the attachment field if that's possible.
The name of the table and fields are :tblDrawings, fName, fPath, fFilePath, and the attachment field. frmGetNewDrawings, btnPreviewDrawings.
For those that may read this and want to suggest that I would normally be better off leaving the files linked instead of attaching, well I agree, except that all users of this database do not have access to the server where the files reside. These users will be accessing through the web so they will need local copies of the files, hence the need for the attachment field use. They will be reading the drawings, they will not be linking and attaching them.
I appreciate the solution to this problem because it's badly needed. I'm awarding maximum points to the quickest and completest solution,.