Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server functions 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 Ac…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

929 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

10 Experts available now in Live!

Get 1:1 Help Now