Go Back   Access World Forums > Microsoft Access Discussion > Tables

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 06-07-2016, 06:42 AM   #1
saints9626
Newly Registered User
 
Join Date: Jun 2016
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
saints9626 is on a distinguished road
Link to File in Field of Table

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

saints9626 is offline   Reply With Quote
Old 06-07-2016, 06:48 AM   #2
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 11,330
Thanks: 40
Thanked 3,667 Times in 3,536 Posts
CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light
Re: Link to File in Field of Table

assuming the order number is part of the file name then build a string when required e.g.

"C:\orders\"& me.ordernum & ".pdf"
__________________
CJ_London
_______________________
A little thanks goes a long way. If you have found this post useful, please tick the thanks button
CJ_London is offline   Reply With Quote
Old 06-07-2016, 06:58 AM   #3
saints9626
Newly Registered User
 
Join Date: Jun 2016
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
saints9626 is on a distinguished road
Re: Link to File in Field of Table

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

saints9626 is offline   Reply With Quote
Old 06-07-2016, 07:09 AM   #4
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 11,330
Thanks: 40
Thanked 3,667 Times in 3,536 Posts
CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light
Re: Link to File in Field of Table

in the onclick event for the ordernum control you would put something like

followhyperlink "C:\orders\"& me.ordernum & ".pdf"
__________________
CJ_London
_______________________
A little thanks goes a long way. If you have found this post useful, please tick the thanks button
CJ_London is offline   Reply With Quote
The Following User Says Thank You to CJ_London For This Useful Post:
saints9626 (06-08-2016)
Old 06-08-2016, 06:30 AM   #5
saints9626
Newly Registered User
 
Join Date: Jun 2016
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
saints9626 is on a distinguished road
Re: Link to File in Field of Table

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
Attached Images
File Type: png error.png (58.3 KB, 68 views)
saints9626 is offline   Reply With Quote
Old 06-08-2016, 06:44 AM   #6
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 11,330
Thanks: 40
Thanked 3,667 Times in 3,536 Posts
CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light
Re: Link to File in Field of Table

click on the three dot button to the right on the event row. Choose the code option and enter the code there
__________________
CJ_London
_______________________
A little thanks goes a long way. If you have found this post useful, please tick the thanks button
CJ_London is offline   Reply With Quote
Old 06-08-2016, 06:53 AM   #7
saints9626
Newly Registered User
 
Join Date: Jun 2016
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
saints9626 is on a distinguished road
Re: Link to File in Field of Table

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
Attached Images
File Type: jpg error.jpg (91.5 KB, 69 views)

saints9626 is offline   Reply With Quote
Old 06-08-2016, 08:02 AM   #8
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 11,330
Thanks: 40
Thanked 3,667 Times in 3,536 Posts
CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light
Re: Link to File in Field of Table

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.
__________________
CJ_London
_______________________
A little thanks goes a long way. If you have found this post useful, please tick the thanks button
CJ_London is offline   Reply With Quote
The Following User Says Thank You to CJ_London For This Useful Post:
saints9626 (06-09-2016)
Old 06-09-2016, 02:18 AM   #9
saints9626
Newly Registered User
 
Join Date: Jun 2016
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
saints9626 is on a distinguished road
Re: Link to File in Field of Table

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
saints9626 is offline   Reply With Quote
Old 06-09-2016, 05:00 AM   #10
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 11,330
Thanks: 40
Thanked 3,667 Times in 3,536 Posts
CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light
Re: Link to File in Field of Table

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

__________________
CJ_London
_______________________
A little thanks goes a long way. If you have found this post useful, please tick the thanks button
CJ_London is offline   Reply With Quote
Reply

Tags
forms , link , pdf , subforms

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Link table with Excel file ScottXe Tables 1 02-01-2015 09:07 AM
Download File from Internet (link on field) and save it(link on field). Ucramos Modules & VBA 2 07-25-2011 04:40 AM
link table to ext. text file martyogelvie Tables 0 03-29-2006 01:55 PM
link table from .mdf (sql srv) file into access db joblot General 1 03-09-2006 06:27 AM
link OLE field to PDF file in next column Real Wally Forms 0 02-02-2003 11:56 PM




All times are GMT -8. The time now is 05:18 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World