concatenate

gripper

Board Regular
Joined
Oct 29, 2002
Messages
176
Hi folks, have a question about a string.

I have a form in Access with a field named domain which has an entry of raw data like "mydomain.com" What I want to do is off to the right to have a hyperlink in a text box that will be "http://www.mydomain.com".

I will use this to check occasionally to see if the site is active.

Thank you very much for your help.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Well, I did it with a label, because hyperlinks don't apply to text boxes.

Anyway, here's all the form's VBA code. I'm assuming the text box on the form -- as opposed to the data field in the table -- is called txtDomain. First add a label to the form, call it lblHyperlink, and change its font to blue and underlined if you want:

Code:
Option Compare Database
Option Explicit
 
' Event handlers
 
Private Sub txtDomain_BeforeUpdate(Cancel As Integer)
    Call MakeLink
End Sub
 
Private Sub txtDomain_AfterUpdate()
    Call MakeLink
End Sub
 
Private Sub Form_Current()
    Call MakeLink
End Sub
 
' Link maker
 
Private Sub MakeLink()
    With Me.lblHyperlink
        .Caption = "[URL]http://www[/URL]." & Me.txtDomain.Value
        .HyperlinkAddress = .Caption
    End With
End Sub

All it does is to update the label based on the text box 1) whenever you change the text box and save it and 2) whenever you move to a new record. You may not even need txtDomain_BeforeUpdate.
 
Upvote 0

Forum statistics

Threads
1,224,607
Messages
6,179,871
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top