Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 11-05-2015, 06:57 AM   #1
crann
Newly Registered User
 
Join Date: Nov 2002
Posts: 160
Thanks: 16
Thanked 0 Times in 0 Posts
crann
Displaying a PDF document link in a form

Hi Guys

Advice on how best to display a link to a PDF file or image from a form.

I have a table which contains information about safety records.
Within the table I have a field called: GasCheck.
This field contains the file path to a scanned copy of a Gas Safety Certificate or PDF document.

I want to display an icon that a user can click to launch that specific file, specific to the record im on and then go on to print etc.

I have been able to display for example a .jpg image but not able to click the icon and actually print it or view it within its own programme, PDF's i cant seem to view at all

Can I do what I am trying to do and how?

Thanks

crann is offline   Reply With Quote
Old 11-05-2015, 07:08 AM   #2
spikepl
Eledittingent Beliped
 
spikepl's Avatar
 
Join Date: Nov 2010
Location: San Serriffe
Posts: 6,144
Thanks: 77
Thanked 980 Times in 958 Posts
spikepl is a jewel in the rough spikepl is a jewel in the rough spikepl is a jewel in the rough
Re: Displaying a PDF document link in a form

look up FollowHyperlink method
__________________

Don't tell us what did not happen.
Do you tell the mechanic about your car "it doesn't work" or vague stuff like:
I couldn't, No joy, To no avail, No go
, Incorrect, Wrong, Seems, Without success, It didn't let me, I/it failed.

Do tell us what did happen
:

I want this ... to happen, I attempted this ..., using this ... code and pressing these buttons, the system did this ... in response, and I got this ... error in this ... line.

Did it help? Pass it forward!

Joys of Access:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

spikepl is offline   Reply With Quote
Old 11-05-2015, 07:52 AM   #3
crann
Newly Registered User
 
Join Date: Nov 2002
Posts: 160
Thanks: 16
Thanked 0 Times in 0 Posts
crann
Re: Displaying a PDF document link in a form

Thanks

OK heres the problem I am having work great if I set the field to a Hyperlink the problem is I share the table information on Sharepoint. For some reason sharepoint wont let me upload table with the hyperlink fields in.

Is there anyway I can keep field as Short Text with the path stored then change the text field on form to open that path as a hyperlink??

Thanks

crann is offline   Reply With Quote
Old 11-05-2015, 07:54 AM   #4
spikepl
Eledittingent Beliped
 
spikepl's Avatar
 
Join Date: Nov 2010
Location: San Serriffe
Posts: 6,144
Thanks: 77
Thanked 980 Times in 958 Posts
spikepl is a jewel in the rough spikepl is a jewel in the rough spikepl is a jewel in the rough
Re: Displaying a PDF document link in a form

Read the documentation for the FollowHyperlink method
__________________

Don't tell us what did not happen.
Do you tell the mechanic about your car "it doesn't work" or vague stuff like:
I couldn't, No joy, To no avail, No go
, Incorrect, Wrong, Seems, Without success, It didn't let me, I/it failed.

Do tell us what did happen
:

I want this ... to happen, I attempted this ..., using this ... code and pressing these buttons, the system did this ... in response, and I got this ... error in this ... line.

Did it help? Pass it forward!

Joys of Access:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

spikepl is offline   Reply With Quote
Old 11-05-2015, 08:09 AM   #5
crann
Newly Registered User
 
Join Date: Nov 2002
Posts: 160
Thanks: 16
Thanked 0 Times in 0 Posts
crann
Re: Displaying a PDF document link in a form

Thanks

Yes I have already been reading many posts but as a beginner struggling to stay on track.

Ive used the code Application.FollowHyperlink for example to open open files etc but Im not sure how I get the code to look for the specific path of each different record within the table. My Hyperlinks just seem to open a fixed path.

I am very happy to read and learn myself i just cant seem to find a post specific to what i am trying to do.

Any help be grateful

Thanks
crann is offline   Reply With Quote
Old 11-05-2015, 10:21 AM   #6
smig
Newly Registered User
 
Join Date: Nov 2009
Location: Israel
Posts: 2,030
Thanks: 78
Thanked 134 Times in 125 Posts
smig is on a distinguished road
Re: Displaying a PDF document link in a form

I use this code:
Code:
Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, 
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Public Function OpenDirApp(WhatToOpen As String)

ShellExecute 0, "Open", WhatToOpen, vbNullString, vbNullString, SW_SHOWNORMAL

End Function
You can send this function whatever you want - Application name (Winword.exe), a file or folder.

It's a function so it can be called from Menu buttons, but it can be a Sub too.
smig is offline   Reply With Quote
Old 11-05-2015, 10:54 PM   #7
HiTechCoach
Newly Registered User
 
HiTechCoach's Avatar
 
Join Date: Mar 2006
Location: Oklahoma City, OK
Posts: 4,254
Thanks: 8
Thanked 156 Times in 144 Posts
HiTechCoach is a jewel in the rough HiTechCoach is a jewel in the rough HiTechCoach is a jewel in the rough HiTechCoach is a jewel in the rough
Re: Displaying a PDF document link in a form

Quote:
Originally Posted by crann View Post
Thanks

OK heres the problem I am having work great if I set the field to a Hyperlink the problem is I share the table information on Sharepoint. For some reason sharepoint wont let me upload table with the hyperlink fields in.

Is there anyway I can keep field as Short Text with the path stored then change the text field on form to open that path as a hyperlink??

Thanks
Are you creating a Web App?

Have you considered storing the files in Shaerpoint?

__________________
Boyd Trimmell
Specializing in Accounting, CRM, and Business solutions
Microsoft Access MVP 2010-2015 , aka
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
HiTechCoach is offline   Reply With Quote
Old 11-06-2015, 12:06 AM   #8
crann
Newly Registered User
 
Join Date: Nov 2002
Posts: 160
Thanks: 16
Thanked 0 Times in 0 Posts
crann
Re: Displaying a PDF document link in a form

Hello

No my db is not a web app. In simple terms I have a copy of the db local on a few different machines but have my tables stored in Sharepoint so data is always saved securely and shared by any user.

I have a business One Drive Account which ive created as a mapped netword drive labelled Z:\ drive. All my files are then saved from any machine to that shared z:\ and I simply reference that path from a Table field within the db.

I have managed to use the following code to access different scanned files from within my form:

Application.FollowHyperlink "Z:\FireCertificates\" & Me.BuildingCode & ".PDF"

In this case when I scan a document I save the name as the Building code which also appears in my form, different for each record. That seems to work really well and actually is quite logical that I save the scanned ducument with a related file name such as the building number.

The only thing is if there are no files scanned in when I click the command button I get and error message appear is it possible to add some code to say if no file is saved display a message box "Please scan a new document" ???

Hope that makes sense.

Thanks
crann is offline   Reply With Quote
Old 11-06-2015, 09:32 AM   #9
HiTechCoach
Newly Registered User
 
HiTechCoach's Avatar
 
Join Date: Mar 2006
Location: Oklahoma City, OK
Posts: 4,254
Thanks: 8
Thanked 156 Times in 144 Posts
HiTechCoach is a jewel in the rough HiTechCoach is a jewel in the rough HiTechCoach is a jewel in the rough HiTechCoach is a jewel in the rough
Re: Displaying a PDF document link in a form

Quote:
Originally Posted by crann View Post
Hello

No my db is not a web app. In simple terms I have a copy of the db local on a few different machines but have my tables stored in Sharepoint so data is always saved securely and shared by any user.

I have a business One Drive Account which ive created as a mapped netword drive labelled Z:\ drive. All my files are then saved from any machine to that shared z:\ and I simply reference that path from a Table field within the db.

I have managed to use the following code to access different scanned files from within my form:

Application.FollowHyperlink "Z:\FireCertificates\" & Me.BuildingCode & ".PDF"

In this case when I scan a document I save the name as the Building code which also appears in my form, different for each record. That seems to work really well and actually is quite logical that I save the scanned ducument with a related file name such as the building number.

The only thing is if there are no files scanned in when I click the command button I get and error message appear is it possible to add some code to say if no file is saved display a message box "Please scan a new document" ???

Hope that makes sense.

Thanks
Sure us the Dir() function to test to see if the filr exist before attempting to opening it.

I recommend that you always test to see if a filr exist before trying to use it.


Example: **** Untested****
Code:
Dim strFilePath as String


strFilePath  = "Z:\FireCertificates\" & Me.BuildingCode & ".PDF"

if Dir(strFilePath ) > "" then 

   Application.FollowHyperlink strFilePath  

Else

  MsgBox "Not Found"
End if
__________________
Boyd Trimmell
Specializing in Accounting, CRM, and Business solutions
Microsoft Access MVP 2010-2015 , aka
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
HiTechCoach is offline   Reply With Quote
The Following User Says Thank You to HiTechCoach For This Useful Post:
crann (11-07-2015)
Old 11-06-2015, 10:25 AM   #10
AccessBlaster
.
 
Join Date: May 2010
Posts: 1,221
Thanks: 29
Thanked 281 Times in 267 Posts
AccessBlaster has a spectacular aura about AccessBlaster has a spectacular aura about
Re: Displaying a PDF document link in a form

Maybe you could use a FileDialog box to pick the pdf or graphic file.
https://msdn.microsoft.com/en-us/lib.../ff196794.aspx
AccessBlaster is offline   Reply With Quote
Old 11-06-2015, 10:33 AM   #11
smig
Newly Registered User
 
Join Date: Nov 2009
Location: Israel
Posts: 2,030
Thanks: 78
Thanked 134 Times in 125 Posts
smig is on a distinguished road
Did you try what I suggested ?
smig is offline   Reply With Quote
The Following User Says Thank You to smig For This Useful Post:
crann (11-07-2015)
Old 11-07-2015, 05:11 AM   #12
crann
Newly Registered User
 
Join Date: Nov 2002
Posts: 160
Thanks: 16
Thanked 0 Times in 0 Posts
crann
Re: Displaying a PDF document link in a form

Thanks for that HiTechCoach worked perfect and makes total sense now to test if a file exists first in the code.
crann is offline   Reply With Quote
Old 11-07-2015, 11:25 AM   #13
HiTechCoach
Newly Registered User
 
HiTechCoach's Avatar
 
Join Date: Mar 2006
Location: Oklahoma City, OK
Posts: 4,254
Thanks: 8
Thanked 156 Times in 144 Posts
HiTechCoach is a jewel in the rough HiTechCoach is a jewel in the rough HiTechCoach is a jewel in the rough HiTechCoach is a jewel in the rough
Re: Displaying a PDF document link in a form

Quote:
Originally Posted by crann View Post
Thanks for that HiTechCoach worked perfect and makes total sense now to test if a file exists first in the code.
You're welcome. Glad we could assist.

__________________
Boyd Trimmell
Specializing in Accounting, CRM, and Business solutions
Microsoft Access MVP 2010-2015 , aka
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
HiTechCoach is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying RTF Document after writing Blob File hturk Modules & VBA 0 09-18-2007 05:14 PM
link word document _Brian_ Reports 0 05-03-2006 10:42 PM
How to link a Word document to Access? Matt123456789 Macros 4 03-01-2006 11:03 PM
Displaying a Word Document INSIDE Access Caitlin11 Forms 1 02-14-2003 09:03 AM
[SOLVED] Link between table and word document Irritater Forms 0 01-22-2000 06:35 AM




All times are GMT -8. The time now is 04:31 PM.


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