Uploading a file and saving it as a link

CBenfer

Registered User.
Local time
Today, 08:42
Joined
Aug 30, 2012
Messages
51
I'm not sure if this is the correct place to put this, but...

I'm going to be creating a database where one of the functions is to provide access to a certain file associated with each record. I'm using Access 2003, so I think I want to link to the files rather than store them directly.

So, what I'd like to do is create some code that basically asks the user to upload a file from his/her PC, saves that file to the same directory the Access DB is in (or a subdirectory), then stores a link to the file in a field so that someone else can access it.

Does that make sense?

Thanks in advance!
 
Hello CBenfer,
The main question is how many files will each user have? If it is always going to be one, then all you need to do is create a field in the table whose data type will be Hyperlink, then use the form control to add or open the files. I use the combination of FileDialog object and Hyperlink methods to achieve this, if no one has responded to this thread I will, when I get to my desk (I do not have Access at home :() tomorrow morning (GMT).. Until then research on FileDialog and Hyperlink methods.. Should get you started..
 
Thanks - it should only be one file per record, so I think the method you described should work. I was a little unsure about the FileDialog, though - and when I tried the example from Microsoft.com it gave me an error. :(

But, I think something along those lines will work for me if I can get it figured out.
 
just in case you can check the attached database if it is more applicable to you
 

Attachments

What is the error that you are receiving?? I hope I am not completely useless without access, I will try to help out..

EDIT: khodr, sorry to interrupt, but not many people might have A2010, so if you could upload a bit older version probably an mdb version it might help many.. Just a suggestion..

Please try khodr example and post back so I do not have to worry about the code tomorrow.. :) Thanks..
 
Last edited:
Sadly, I only have MS Access 2003 - can you save it as an older version for me?
 
here you go, this is an older version Access format, you have to be able to open it now with your Access version 2003
 

Attachments

Hello CBenfer, I just looked over the code by khodr, unless you understand how it works completely do not just copy and paste it.. As it will lead to so many unanswered questions..

I have attached a new changed copy, I have used the same method I asked you to research upon.. FileDialog, it only needs you to add a Reference "Microsoft Office 14.0 Library", then it will work good..

So what I have done in the DB is I have added a sampleTable that has only three fields Customer Name (Text), ID (AutoNumber), FileLink (Hyperlink)..
Next, I create a Bound Form that will have the link field in the Form so when you click on it, if there is a file then it will be opened for you.. If not then A file Dialog will open asking you to select a file.. Then uses InStr(), Mid() to determine the FileName you chose and the path of the file and stores in a format
Code:
yourFileName # yourFilePath
' eg. HELL.xls # C:\Users\XXX\Documents\HELL.xls
 

Attachments

Thanks all - I think that'll work for what I'm trying to do. Now I just need to figure out the rest of the database. :)
 
Hello CBenfer, I just looked over the code by khodr, unless you understand how it works completely do not just copy and paste it.. As it will lead to so many unanswered questions..

I have attached a new changed copy, I have used the same method I asked you to research upon.. FileDialog, it only needs you to add a Reference "Microsoft Office 14.0 Library", then it will work good..

So what I have done in the DB is I have added a sampleTable that has only three fields Customer Name (Text), ID (AutoNumber), FileLink (Hyperlink)..
Next, I create a Bound Form that will have the link field in the Form so when you click on it, if there is a file then it will be opened for you.. If not then A file Dialog will open asking you to select a file.. Then uses InStr(), Mid() to determine the FileName you chose and the path of the file and stores in a format
Code:
yourFileName # yourFilePath
' eg. HELL.xls # C:\Users\XXX\Documents\HELL.xls

Thanks Pr2 for the Professional Interaction, I strongly recommand who tries to use the sample databases on their project to understand every code they are trying to use from other users else we will never learn to do it ourselves,
thanks again
 
pr2-eugin,

I have found the code in the changed version extremely useful and thank you for it. How could I alter it to return the unc network path instead of a drive letter based result?

I'm using this in a project across many users who all probably have their drives mapped differently to each other.

any input would of course be much appreciated.

Thanks in advance.

Gary




Hello CBenfer, I just looked over the code by khodr, unless you understand how it works completely do not just copy and paste it.. As it will lead to so many unanswered questions..

I have attached a new changed copy, I have used the same method I asked you to research upon.. FileDialog, it only needs you to add a Reference "Microsoft Office 14.0 Library", then it will work good..

So what I have done in the DB is I have added a sampleTable that has only three fields Customer Name (Text), ID (AutoNumber), FileLink (Hyperlink)..
Next, I create a Bound Form that will have the link field in the Form so when you click on it, if there is a file then it will be opened for you.. If not then A file Dialog will open asking you to select a file.. Then uses InStr(), Mid() to determine the FileName you chose and the path of the file and stores in a format
Code:
yourFileName # yourFilePath
' eg. HELL.xls # C:\Users\XXX\Documents\HELL.xls
 
Gary, Welcome to AWF.. :)

Am glad it is working out for you.. Regarding your Query.. I am not quiet clear.. This thread was more than three months old.. So, is it possible for you to post a new thread describing your problem and the things you have done so far?
 
Paul,
Thank you so very much for uploading the database file!! This is exactly what I was wanting to do, but I just did not know the first place to start. This is a tremendous help.
 
leblanc9425, am glad it is helping you.. :) If you have any doubts/stuck up please create a new thread, we might be able to help you out.. Good Luck..
 

Users who are viewing this thread

Back
Top Bottom