robotman757
Programmer
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
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