Hyperlinks

G

gavin

I'm not sure if I've understood this right or if I'm just doing something
wrong - maybe someone can help me?

I think it should be possible to have a field of the data type hyperlink and
to link to a document (PDF for example) on my hard drive and by clicking
that hyperlink to have the document open?

Well if that is the case it's not working for me and yet it seems like it
should be straightforward. I have a field of the correct data type in my
table. I have a data entry form and have clicked in the relevant filed and
have selected Insert>Hyperlink and have navigated to the file in question.
The file has an application associated with it - but it doesn't open.

Can anyone suggest what the problem might be? I'd be grateful for any help.
 
D

Dale Fye

If you have a text field in a form, you should be able to copy the URL (or
path\file name) from your web browser or windows explorer, and paste that
value into the text field on your form. Then, when you click on that
textbox, it should navigate you to the URL or file.

Personally, I dislike the hyperlink datatype, and prefer to use text or memo
fields (for really long URLs). Then, I put a command button next to the
textbox on my forms and use the application.followhyperlink method in the
Click event of that button to follow the hyperlink to the URL or file.

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 
R

Ron2006

1) you have NOT told us what is happening, if anything.

2) Another way is to have the field be simply a txt field and as long
as you can establish the entire path for the document name that you
place there you can have the <dbl-click> event issue the following

application.followhyperlink entirepathnameforfile


This usually makes it easier to input data since the user can simply
enter the actual file name AS LONG AS the rest of the path information
can be optained.

If this is a split split application or multi user application, having
something on YOUR hard drive will not work since the other users will
most like NOT be able to get to the file since C:\ will be
considered to be on THEIR hard drive.

Ron
 
G

gavin

Ron2006 said:
1) you have NOT told us what is happening, if anything.

2) Another way is to have the field be simply a txt field and as long
as you can establish the entire path for the document name that you
place there you can have the <dbl-click> event issue the following

application.followhyperlink entirepathnameforfile


This usually makes it easier to input data since the user can simply
enter the actual file name AS LONG AS the rest of the path information
can be optained.

If this is a split split application or multi user application, having
something on YOUR hard drive will not work since the other users will
most like NOT be able to get to the file since C:\ will be
considered to be on THEIR hard drive.

Ron

Many thanks for that, Ron. Actually nothing was happening!

I shall try your work round tomorrow.

Your help is appreciated.
 
G

gavin

Dale Fye said:
If you have a text field in a form, you should be able to copy the URL (or
path\file name) from your web browser or windows explorer, and paste that
value into the text field on your form. Then, when you click on that
textbox, it should navigate you to the URL or file.

Personally, I dislike the hyperlink datatype, and prefer to use text or
memo
fields (for really long URLs). Then, I put a command button next to the
textbox on my forms and use the application.followhyperlink method in the
Click event of that button to follow the hyperlink to the URL or file.

Many thanks also to you, Dale. Hopefully I should be sorted now.
 
G

gavin

Dale Fye said:
If you have a text field in a form, you should be able to copy the URL (or
path\file name) from your web browser or windows explorer, and paste that
value into the text field on your form. Then, when you click on that
textbox, it should navigate you to the URL or file.

Personally, I dislike the hyperlink datatype, and prefer to use text or
memo
fields (for really long URLs). Then, I put a command button next to the
textbox on my forms and use the application.followhyperlink method in the
Click event of that button to follow the hyperlink to the URL or file.

I had a go at this today, Dale, but I have to admit that I'm pretty clueless
with VBA - and it didn't work! Either because my code was wrong - or for
another reason entirely.

My code is:

Private Sub Command52_Click()

Application.FollowHyperlink ("R:\..............\Thank you letter.pdf")

End Sub

The PDF is on a network (R:\) drive.

When I click the command button to fire this code it looks like something is
trying to happen because the screen kind of flickers - that's not describing
it too well - but I don't get an error message.

Is the code OK? What else could it be?
 
D

Dale Fye

gavin

Have you checked to see whether it opened in the background (behind Access)?
I just ran that code in the immediate window of A2007, and it flashed, then
showed me the access window again. When I did Alt-Tab, it showed me the
Word document I had opened, with it visible.

I'm not sure why it did not make word the active application. This is the
first time I've used that code in 2007, but it has worked great for me in
2003, in the past.

Dale
 
G

gavin

Dale Fye said:
gavin

Have you checked to see whether it opened in the background (behind
Access)? I just ran that code in the immediate window of A2007, and it
flashed, then showed me the access window again. When I did Alt-Tab, it
showed me the Word document I had opened, with it visible.

I'm not sure why it did not make word the active application. This is the
first time I've used that code in 2007, but it has worked great for me in
2003, in the past.

Dale

Hi Dale,
That was exactly what was happening for me - the screen just flashed but
Access was still the active Window - and the target document did not appear
on the task bar. However, having tried this again and doing what you
suggest, i.e. Alt-Tab, I find that the application is indeed open! Slightly
odd behaviour - a minor bug? - but at least it's working!

Thanks for persevering with me, Dale - it's much appreciated!
 
D

Dale Fye

Gavin,

If you know the application, you can probably get the hwind for it (google
that term along with VBA), and will probably be able to figure out a way to
make it open on top of Access.

Have a Merry Christmas

Dale
 
G

gavin

Dale Fye said:
Gavin,

If you know the application, you can probably get the hwind for it (google
that term along with VBA), and will probably be able to figure out a way
to make it open on top of Access.

Have a Merry Christmas

Dale

Many thanks Dale - but having done a quick Google I fear that is above my
abilities - this group is called "gettingstarted" after all :)

A very merry Christmas to you too!
 
D

Dirk Goldgar

gavin said:
Many thanks Dale - but having done a quick Google I fear that is above my
abilities - this group is called "gettingstarted" after all :)


You might try the code posted here:

http://www.mvps.org/access/api/api0018.htm
API: Start an app with ShellExecute

Yes, it calls the Windows API, which can be a bit intimidating at first
sight, but all you have to do is copy all the code between the "** Code
Start **" and "** Code End **" comments into a new standard module, save
that module as, say, "modHandleFile", and then call the fHandleFile
function in your form's code like this:

fHandleFile "R:\..............\Thank you letter.pdf", WIN_NORMAL

That works for me, and brings the newly opened application to the front.
I'm not sure why FollowHyperlink is opening it in back, though, so please
let me know if the above method doesn't work for you.
 

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