Link to File in Field of Table (1 Viewer)

saints9626

New member
Joined
Jun 7, 2016
Messages
5
Hello,

Sorry if this has already been asked but after many searches I cannot find an answer.

I have a Form, containing a Subform, in the subform is a field called "Order No". This number will be entered on the subform, but i wish for this to become a link to the corresponding PDF file upon clicking.

Many thanks for any help.

Joe
 

CJ_London

Super Moderator
Staff member
Joined
Feb 19, 2013
Messages
11,574
assuming the order number is part of the file name then build a string when required e.g.

"C:\orders\"& me.ordernum & ".pdf"
 

saints9626

New member
Joined
Jun 7, 2016
Messages
5
The file name is the exact same as the text in the field. Is there a way to automate that slightly? i.e. the user just enters the order number and it then becomes a link?

Thanks for the reply
 

CJ_London

Super Moderator
Staff member
Joined
Feb 19, 2013
Messages
11,574
in the onclick event for the ordernum control you would put something like

followhyperlink "C:\orders\"& me.ordernum & ".pdf"
 

saints9626

New member
Joined
Jun 7, 2016
Messages
5
Hi, I typed the following code into the "on click" property of the text box used for the order number in the form.

=[FollowHyperlink]="Y:\Orders\" & [me].[Text45] & ".pdf"

Y:\Orders| being where the PDF is saved. PDF Named "19109".

Text45 being the name of the text box on the subform where the order number is inputted.

order number inputted to text45 is "19109"

I have attached a picture of the error returned
 

Attachments

CJ_London

Super Moderator
Staff member
Joined
Feb 19, 2013
Messages
11,574
click on the three dot button to the right on the event row. Choose the code option and enter the code there
 

saints9626

New member
Joined
Jun 7, 2016
Messages
5
Thankyou for the help,

After doing what you said a new error appears;

"Compile Error:

Syntax Error"

I have also attached a shot of the debugger in VBA after this error code is displayed.

Many Thanks
 

Attachments

CJ_London

Super Moderator
Staff member
Joined
Feb 19, 2013
Messages
11,574
check my original post - you have just copied what you had before which is not correct for vba, you need to lose both the = and the square brackets.
 

saints9626

New member
Joined
Jun 7, 2016
Messages
5
That's now working brilliantly thank-you!

Don't suppose there's a way to look for a file across multiple folders? I wish to have another link similar but the files are sorted in folders ie. "0-99" - "100-199" - "200-299" etc.

Any help much appreciated
 

CJ_London

Super Moderator
Staff member
Joined
Feb 19, 2013
Messages
11,574
not without more code to look through directories - regret I am now away for a couple of weeks so suggest start a new thread.

Google 'access vba filedialog' and 'access vba dir function' to find the basic functions required
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom