?
Solved

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

Posted on 2014-11-17
4
Medium Priority
?
190 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 48

Expert Comment

by:Dale Fye
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 48

Accepted Solution

by:
Dale Fye earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Suggested Courses

752 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