hyperlink from data

A

Angi

I realize I'm going post crazy, but I've got a lot of questions!
Sorry!

I know how to insert a hyperlink, but how do I create a hyperlink from
data that is already there? I have an email field and when it displays
on the company info form, I want to be able to click it and open up
Outlook or whatever email program I need. I've set the IsHyperlink
property to yes, but that just makes it look like a hyperlink. Is
there coding I need to put in the OnClick event or am I missing
something easier? If I do need to put code in, what command should I
be using.

TIA...again!
 
A

Angi

Thank you for that! Now just a couple more questions. I've copied and
created the module EmailMod. On my form in the email field, I've set
IsHyperlink to yes and have the following in the OnClick event:

Private Sub Email_Click()
dim stFile as string
stFile = "mailto:" & Me!
EMailMod
End Sub

I'm getting the error:
Compile Error
Expected variable or procedure, not module

I've tried changing it to EmailMod (stFile) but that didn't work
either. What am I doing wrong? I'm feeling really stupid right now!
 
J

John Nurick

Does anyone have any other ideas on this one?

Usually one doesn't need to install a special module or anything. Just
use something like this in the double-click event or wherever:

Application.FollowHyperlink "mailto:" & Me.ActiveControl.Value

FollowHyperlink will see the mailto: protocol and tell Windows to launch
the default email client and create an email to that address.

I suggested the double-click event because it drives me mad if a field
(as opposed to a button) does something active every time I click on
it<g>.
 
A

Angi

Well that was easy! I even figured it for the URL field. I'm still
having the highlighting problem when the user clicks the field, but
I'll figure something out. Thanks, John!
 
J

John Nurick

highlighting problem when the user clicks the field

Put code in the textbox's Enter event procedure that manipulates its
SelStart and SelLen properties (or other properties) to get the effect
you want. E.g. to highlight the entire contents, use something like this
air code:

Private Sub txtXXX_Enter()
With Me.ActiveControl
.SelStart = 0
.SelLen = Len(.Text)
End With
End Sub

or to turn it blue on entry and back to normal on exit

Private Sub txtXXX_Enter()
Me.ActiveControl.BackColor = 16711680
End Sub

Private Sub txtXXX_Exit(Cancel As Integer)
Me.ActiveControl.BackColor = 16777215
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top