How do I make adding a hypre link easier?

  • Thread starter bbrazeau via AccessMonster.com
  • Start date
B

bbrazeau via AccessMonster.com

I would like to make the process of adding a hyper link to a record easier
and more intuitive. I know that to establish the hyperlink at the form level
I can right click the empty hyperlink box and choose hyperlink,edit hyperlink,
make a choice on what type of hyperlink from the left side panel, click file:
under browse for, navigate to the proper directory, ensure that "all files"
is selected under Files of type:(so the pdf file I want is visible),then
double click the file I want to point to, then click OK in the dialog box.
However since the type of link, location, and type of file will always be the
same, is there a way thru VB or something to make it simpler? Say by having
the user click a button, or double click the empty hyperlink which would make
all the choices, and navigation ahead of time and require them simply to
click the file and OK? Any help would be appreciated.
 
B

bbrazeau via AccessMonster.com

Thanks Rob but I found an easier way of doing what I want and I'll share it
here: some stipulations first
1). the files you want to open (hyperlink to) with this method must all be in
the same directory (because I hard coded the path).
2). They must all be of the same type (because I hard coded the file
extension). I'm opening "pdf" files
3). There must be a text box on your form that has the name of the file to
open (and each file must have a unique name) obviously. the text box on my
form is called "Drawing"
4). You make a button on your form called (cmdOpenDrawing) and in it's on
click event code you enter the code below: Note the "Some path" would be
replaced with the complete path to the directory where the files are stored.
5). When you click the button on the form it opens the file with a name that
matches the text field "Drawing" for that record. P.S. This example is in the
Access help files under Hyperlink property example. It's just pretty much a
useless example so I modified it a little to simplify it and make it actually
do something useful.

Option Compare Database

Private Sub cmdOpenDrawing_Click()
CreateHyperlink Me!cmdOpenDrawing
End Sub

Sub CreateHyperlink(ctlSelected As Control)
Dim hlk As Hyperlink
Dim DirectoryPath As String
Dim DrawingToOpen As String
DrawingToOpen = Me.Drawing & ".pdf"
DirectoryPath = "C:\Some path\" & DrawingToOpen
Select Case ctlSelected.ControlType
Case acLabel, acImage, acCommandButton
Set hlk = ctlSelected.Hyperlink
With hlk
If Not IsMissing(DirectoryPath) Then
.Address = DirectoryPath
Else
.Address = ""
End If
.SubAddress = DirectoryPath
.Follow
.Address = ""
.SubAddress = ""
End With
Case Else
MsgBox "The control '" & ctlSelected.Name _
& "' does not support hyperlinks."
End Select
End Sub

Rob said:
Use this:

http://www.mvps.org/access/api/api0001.htm

to browse to the target file and then set the properties of your hyperlink
using the file name returned.
I would like to make the process of adding a hyper link to a record easier
and more intuitive. I know that to establish the hyperlink at the form level
[quoted text clipped - 8 lines]
all the choices, and navigation ahead of time and require them simply to
click the file and OK? Any help would be appreciated.
 

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