LINK TO DOCS

J

jo

Hi on a form the user would type in the path to their document, what i would
like is the user to be able to view that document if needed maybe by clicking
on a button that reckonizes the address in the Path cell. is this possible?
and if so can someone give me the steps to do this thank you.
Jo
 
D

Daniel Pineault

Not a problem.

Let say you have a form in which you have a control named "DocPath" which
store the full path and filename of a given doc. You could then create a
button and using the on_click event set it up to open the specified doc.

The command button code could use 1 of 2 possible approached.

1. FollowHyperlink
Application.FollowHyperlink Me.DocPath

2. Shell
For more detail use the help file, it has a good explanation and examples.
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
H

Hans Up

jo said:
Hi on a form the user would type in the path to their document, what i would
like is the user to be able to view that document if needed maybe by clicking
on a button that reckonizes the address in the Path cell. is this possible?
and if so can someone give me the steps to do this thank you.

You can use FollowHyperlink to open up the document in whatever
application is registered for that document type.

Say your button is named cmdYourButton, and the text box with the file
path is named txtPath, this code in the button's click event should do
what you're asking. Figure out what error handling you want to add ...
for example if the user clicks the button without having entered a
document path in the text box.

Private Sub cmdYourButton_Click()
Application.FollowHyperlink Me.txtPath
End Sub
 
J

jo

hi guys this is exactly what i want but I think I am doing something wrong as
I am getting an error.
This is the code:
Private Sub cmdOpenFile_Click()

Application.FollowHyperlink Me.ReferenceMasterID

End Sub

and the doc path is: C:\Users\Joeblogs\Desktop\terry accounts\terry resume

Not sure what is wrong?
 
D

Daniel Pineault

What does the control ReferenceMasterID return as a value? The document
filename? Then try:

Private Sub cmdOpenFile_Click()
sDocPath As String

sDocPath = "C:\Users\Joeblogs\Desktop\terry accounts\terry resume\"
Application.FollowHyperlink sDocPath & Me.ReferenceMasterID
End Sub

When you use the FollowHyperlink Method, you have to supply the Full path
and file name.

If this doesn't work, please post the error you receive and an example of
the ReferenceMasterID values.
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
J

jo

ReferenceMasterID is the field that the user would put in their path address
for the file.
I have changed the field properties to Hyperlink = yes
and when I type the path required c:\users\joebloggs\desktop\terry
accounts\Resume terry blankley.doc
then edit hyperlink i get the follinf address which has this extra part
included
terry accounts\Resume terry
blankley.doc#terry%20accounts/Resume%20terry%20blankley.doc#
The link now works? I thought that the user would just have to type in the
full address and it would work. All I need to do is show the users how to
edit their hyperlinks.
Thank u
jo
 
H

Hans Up

jo said:
hi guys this is exactly what i want but I think I am doing something wrong as
I am getting an error.

What is the error?
This is the code:
Private Sub cmdOpenFile_Click()

Application.FollowHyperlink Me.ReferenceMasterID

End Sub

and the doc path is: C:\Users\Joeblogs\Desktop\terry accounts\terry resume

What is the "doc path"? Is that the full path to the file? The value
contained in Me.ReferenceMasterId?

Try revising your button click code to verify what value you're feeding
to FollowHyperlink.

Private Sub cmdOpenFile_Click()
MsgBox "ReferenceMasterID: '" & Me.ReferenceMasterID & "'"
Application.FollowHyperlink Me.ReferenceMasterID
End Sub
 
J

jo

Hi ReferenceMasterID is just the name of the field the User would type in the
Path address of the file they are adding to the database (Doc Path, document
path)
I have put yr code in place and it verifies the path but it would seem I
still need to add the extra part with the 20 and # % signs?

I thought all you would need is: terry accounts\Resume terry blankley.doc
but i need to add the following:
#terry%20accounts/Resume%20terry%20blankley.doc#

terry accounts\Resume terry
blankley.doc#terry%20accounts/Resume%20terry%20blankley.doc#
 
H

Hans Up

jo said:
Hi ReferenceMasterID is just the name of the field the User would type in the
Path address of the file they are adding to the database (Doc Path, document
path)
I have put yr code in place and it verifies the path but it would seem I
still need to add the extra part with the 20 and # % signs?

I thought all you would need is: terry accounts\Resume terry blankley.doc
but i need to add the following:
#terry%20accounts/Resume%20terry%20blankley.doc#

I created a form with a text box named ReferenceMasterID. It is NOT
formatted as a hyperlink.

I added a command button named cmdOpenFile. This is the code I used for
the button's click event.

Private Sub cmdOpenFile_Click()
Application.FollowHyperlink Me.ReferenceMasterID
End Sub

If I type the full path to a word document, C:\Access\sample.doc, into
the text box, then click the command button, Word starts up with sample.doc.

Isn't that what you wanted in the first place?
 
J

jo

Hi Hans the problem was the filename the user gave me as an example!! Because
either way I had the field Hyperlink= Yes or No the code worked on other
files that I tried but not this particular one. So now its good. And easier
to just type in the file name. So thanks very much for your time most
appreciated.
Jo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top