Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format Hyperlink Fields 1

Status
Not open for further replies.

MeldrethMan

Technical User
Feb 3, 2012
69
0
0
GB

Is it possible to format a hyperlink field and change its behaviour when clicked?

I'm displaying a list of links in a subform in datasheet view and it looks messy with the underlining and colour changes.
 
I thought this would be easy, but it seems that if it is a hyperlink it will display that way in datasheet view. To work around it I added another text box to the form.

my hyperlink field is "hyperField" and it is displayed in "txtBxHyperField".
my added text box is "txtBxDisplayHyperText"

I added a function to a standard module

Code:
Public Function DisplayHyperFieldText(strHyper As Variant) As String
  If Not IsNull(strHyper) Then
    DisplayHyperFieldText = Split(strHyper, "#")(0)
  End If
End Function
That becomes the control source of my new text box "txtBxDisplayHyperText"
=DisplayHyperFieldText

So in the form module I first hide the real hyperlink field
Code:
Private Sub Form_Load()
  Me.txtBxHyperfield.ColumnHidden = True
End Sub
and put in a click event for the fake hyperlink field
Code:
Private Sub TxtBxDisplayHyperText_Click()
  FollowHyperlink (Me.txtBxHyperfield.Hyperlink.Address)
End Sub
 
Thanks MajP, this looks useful.

Duane, couldn't find any properties for a hyperlink field and searches suggested there weren't any options.
 
couldn't find any properties for a hyperlink field and searches suggested there weren't any options.
There is a property "Display as Hyperlink", but this only allows you to display a text field as a hyperlink: "always, only if hyperlink, on screen". There is no choice to not display as hyperlink. I could not find a way to make a hyperlink not display as a hyperlink in datasheet view. There may be an easier way, but this work-around was the only thing I could come up with.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top