A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Still can't figure out FollowHyperlink



 
 
Thread Tools Display Modes
  #1  
Old November 30th, 2009, 02:59 PM posted to microsoft.public.access.forms
laura.dodge
external usenet poster
 
Posts: 24
Default Still can't figure out FollowHyperlink

Hi, I've tried to search online for what seems like it should be a
simple solution, but I still can't figure it out. I have a form in
Access 2003. I have a control called PubLink1 that is a hyperlink.
When I click on the hyperlink the pdf opens perfectly. However, to
make the form more user-friendly (and to save space) I would like to
create a command button called CmdPubLink1 that says 'Open
Publication' instead of having the user click on the hyperlink. Here's
what I have so far:

Private Sub CmdPubLink1_Click()
On Error GoTo Err_CmdPubLink1_Click

Application.FollowHyperlink PubLink1, , True

Screen.PreviousControl.SetFocus
DoCmd.FindNext

Exit_CmdPubLink1_Click:
Exit Sub

Err_CmdPubLink1_Click:
MsgBox Err.Description
Resume Exit_CmdPubLink1_Click

End Sub

When I click on the command button I get the warning message "Opening
"" Hyperlinks can be dangerous..." And then "Microsoft Office Access
can't follow the hyperlink to '#S:\File.pdf#'."

Does anyone see what I'm doing wrong? Thanks so much for your help!
  #2  
Old November 30th, 2009, 03:20 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default Still can't figure out FollowHyperlink

"laura.dodge" wrote in message
...
Hi, I've tried to search online for what seems like it should be a
simple solution, but I still can't figure it out. I have a form in
Access 2003. I have a control called PubLink1 that is a hyperlink.
When I click on the hyperlink the pdf opens perfectly. However, to
make the form more user-friendly (and to save space) I would like to
create a command button called CmdPubLink1 that says 'Open
Publication' instead of having the user click on the hyperlink. Here's
what I have so far:

Private Sub CmdPubLink1_Click()
On Error GoTo Err_CmdPubLink1_Click

Application.FollowHyperlink PubLink1, , True

Screen.PreviousControl.SetFocus
DoCmd.FindNext

Exit_CmdPubLink1_Click:
Exit Sub

Err_CmdPubLink1_Click:
MsgBox Err.Description
Resume Exit_CmdPubLink1_Click

End Sub

When I click on the command button I get the warning message "Opening
"" Hyperlinks can be dangerous..." And then "Microsoft Office Access
can't follow the hyperlink to '#S:\File.pdf#'."

Does anyone see what I'm doing wrong? Thanks so much for your help!



A hyperlink *field* is actually a text field that stores not only the
hyperlink address itself, but also optional parts such as the display text,
screen tip, and subaddress. The parts are all separated by "#" characters.
Because the field is marked as a hyperlink, when you just click on it,
Access knows to separate out the address part and "follow" it. When you use
the FollowHyperlink method in VBA code, though, you must pass just the
address itself, as a string.

You could use the Split() function to separate out the parts of the
hyperlink field, but there's a HyperlinkPart() function to make it easier.
Try this:

Application.FollowHyperlink HyperlinkPart(Me.PubLink1, acFullAddress)


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #3  
Old November 30th, 2009, 03:38 PM posted to microsoft.public.access.forms
laura.dodge
external usenet poster
 
Posts: 24
Default Still can't figure out FollowHyperlink

Thanks Dirk, that worked wonderfully!

For anyone else having a similar problem, I just wanted to let you
know that I took the following code out:

Screen.PreviousControl.SetFocus
DoCmd.FindNext

because it caused an error message saying "You didn't specify search
criteria with a FindRecord action."
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:45 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.