Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code to edit hyperlink for email

Status
Not open for further replies.

robotman757

Programmer
Joined
Jan 3, 2003
Messages
14
Location
US
I had tried for a few weeks to find a way to store email addresses in a table called Employees. All the basic info is on this table and is modified by using the Employee form. I added a textbox to this form and set its visible property to false and then named it EmailNameformatted. This helped me in many ways. I needed this to make it easier to send an email, so whenever the field EmailName is referenced, it will have the proper address. This is the code I used:

Private Sub EmailName_BeforeUpdate(Cancel As Integer)
Dim stDisplayText As String
Dim stAddress As String
Dim stTooltip As String

'This is used to get the email address and manipulate it to just display the address
'but open the default email program with the message already addressed

stAddress = HyperlinkPart(Me![EmailName], acAddress)
stDisplayText = HyperlinkPart(Me![EmailName], acAddress)
'This is done so the display text will be the actual address
stTooltip = "Email"

stDisplayText = Right$(stDisplayText, Len(stDisplayText)-7)
stAddress = Right$(stAddress, Len(stAddress) - 7)
stAddress = "mailto:" & stAddress
Me![EmailNameformatted] = stDisplayText & "#" & stAddress & "#" & "" & "#" & stTooltip

End Sub


Private Sub EmailName_AfterUpdate()
'This code copies the correct format back into the displayed format on the form.
Me![EmailName] = Me![EmailNameformatted]
'Remember that the EmailNameformatted is not visible!!

End Sub


This allows me to just type the address and not have to worry about editing the files or making it more cluttered by adding "mailto:" the address!!

Dan Walker
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top