Solved

Make a text field on a form a hyperlink if a checkbox is true

Posted on 2014-11-17
4
174 Views
Last Modified: 2014-11-17
I'm trying to make a text box value a hyperlink if a checkbox is true.  Here is my code which isn't working...

    If Me.chkbxHyperlink = True Then
        Me.txtName.Hyperlink = True
    End If

    If Me.chkbxHyperlink = False Then
        Me.txtName.Hyperlink = False
    End If

Open in new window

0
Comment
Question by:SteveL13
  • 2
  • 2
4 Comments
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 40447256
Nah, you don't want to do that.  The underlying data field must be either text or hyperlink, cannot be both, and you really don't want to make it a hyperlink.

What I would recommend is that you include a button to the right of the field, and if the checkbox is checked, enable that button, then use the Application.FollowHyperlink method to follow the hyperlink to the URL or file or email or whatever is associated with the txtName field.

An alternative would be to used the textboxes double click event and if the checkbox is clicked, then use the Application.Followhyperlink method.  Generally the same as above but with a double click on the textbox rather than using a command button.
0
 

Author Comment

by:SteveL13
ID: 40447723
Ok.  I have the checkbox named chkbxHyperlink.  And I have this code in the form:

Function GetHyperlink() As Boolean
    Dim strInput As String
 
    On Error GoTo Error_GetHyperlink
    strInput = Me.txtAwards
    Application.FollowHyperlink strInput, , True
    GetHyperlink = True
 
Exit_GetHyperlink:
    Exit Function
 
Error_GetHyperlink:
    MsgBox Err & ": " & Err.Description
    GetHyperlink = False
    Resume Exit_GetHyperlink
End Function

Open in new window


And I have a command button named cmdGoToHyperlink.  And for the onclck event of the command button I have this code:

    Call GetHyperlink

Open in new window


But it is not taking me to the web address specified in a field named txtHyperLink

I'm sure I don't have any of this right.
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 40447762
you are referring to the txtAwards control in your GetHyperlink function, not to txtHyperlink.  Start out with that.

Personally, I think I would simpl do:

Private Sub cmdGoToHyperlink_Click

    if Me.chkbxHyperlink Then Application.Followhyperlink me.txtHyperlink, , True

End Sub

Open in new window

0
 

Author Closing Comment

by:SteveL13
ID: 40447822
That'll do it.  Worked!  Thanks.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now