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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|