Hi, Mike.
If I understand your question correctly, the hyperlink field on your form is
displaying something like:
"
http://support.microsoft.com/default.aspx?scid=fh;EN-US;kbhowto&sd=MSDN&ln=EN-US&FR=0"
and you expect something more meaningful, such as: "Search Knowledge Base"
for the user to click to open the hyperlinked document. Here's how to fix
that:
1. Place the cursor over the hyperlink field in your form (or table) for
the record that you want to change the display string, and press the right
mouse button. A pop-up menu will appear.
2. Click on "Hyperlink" and a submenu will appear.
3. Click on the "Display Text" field on the submenu and type whatever text
string that you want to appear in the hyperlink field for that record.
4. Press the <ENTER> key or click anywhere outside of the submenu to close
the menu and place your text string into the hyperlink field.
As for your second question, in order to have the "Insert/Edit Hyperlink"
dialog window open with a specific directory displayed in the "Link to file
or URL:" combo box, you need to pass that information to the dialog window.
The easiest way to do that is to put the desired directory's string value in
the hyperlink field of the current record, then open the "Insert/Edit
Hyperlink" dialog window and let the user browse for the file to be
hyperlinked to -- starting at the directory that you desired. However, if
the user doesn't edit the hyperlink, the code will need to replace the
desired directory's string value with the original value as soon as the
"Insert/Edit Hyperlink" dialog window closes, so that the user never sees
that the programmer is "fiddling" with the record.
The following example is one way to programmatically call the "Insert/Edit
Hyperlink" dialog window and have it default to the "C:\Temp" directory,
without replacing the original hyperlink if the user hits the "Cancel" button
or doesn't select a file to hyperlink to.
' * * * * Start code * * * *
Option Compare Database
Option Explicit
Private Const USER_CANC As Long = 2501
Private Sub EditHypLinkBtn_Click()
On Error GoTo ErrHandler
Dim sDefaultDir As String
Dim sOrigText As String
sDefaultDir = "C:\Temp" ' Default directory for the "Edit Hyperlink"
dialog box.
Me!txtHypLink.SetFocus
sOrigText = Me!txtHypLink.Text ' Save value in case user doesn't edit
the hyperlink.
Me!txtHypLink.Text = sDefaultDir
RunCommand acCmdEditHyperlink ' Call the "Insert/Edit Hyperlink"
dialog window.
'---------------------------------------------------------------------
' Determine whether user didn't edit the hyperlink.
'---------------------------------------------------------------------
If (Me!txtHypLink.Text = sDefaultDir) Then
Me!txtHypLink.Text = sOrigText ' Replace orig. hyperlink
string value.
End If
Exit Sub
ErrHandler:
If (Err.Number = USER_CANC) Then ' User cancelled action.
Resume Next
Else
MsgBox "Error in EditHypLinkBtn_Click( ) in " & _
vbCrLf & Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & Err.Description
End If
End Sub ' EditHypLinkBtn_Click( )
' * * * * End code * * * *
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
- - -
When you see correct answers to your question, please sign in to Microsoft's
Online Community and mark these posts, so that all may benefit by filtering