Solved

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

Posted on 2014-11-17
4
183 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 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
default value of combobox 25 40
Null or "" 28 53
Access 2010 7 45
How can I set my Access Query up to filter out specific records 13 25
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

733 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