• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 571
  • Last Modified:

Hyperlink Email Field Error

I am having an issue with an email field set as a hyperlink in the properties
If I click on the field, I can email directly from the field,but my Cmd button to email the contact in the top of the form, pastes two email addresses. when I looked in the table, there is a long string like the following:
 Cheryle@......com#mailto:Cheryle@......com# (example address)
Needless to say outlook won't email this address.
I have the email field set to hyperlink, so that I can click on the field to email, but would also like to email from link on form as well.
Is there a way to fix the code to work, or am I stuck with one option to email, either from the cmd button (and cleaning up the hyperlink stuff in the table) or the clicking on the field.
Below is a screen shot of macro
 email issue
0
Cherylec
Asked:
Cherylec
  • 3
  • 3
  • 2
1 Solution
 
Simon BallCommented:
you need to feed the shortened email address by stripping the character before the #( which is the start of the hyperlink "code"

I would declare a string variable and pop the email address field into it, taking Left([employeeemailaddress] up to the  # character
dim EmpEmail as string
EmpEmail = Left(employeeemailaddress, InStr(employeeemailaddress, "#") - 1)

Open in new window


Then use EmpEmail in the code.
0
 
Simon BallCommented:
aaah, just realised my error.  conver the macro into VB code.... and run that from the button...

you can click on a macro and save as a module to get it translated into VBA by access, then use that as the onclick event of the command button.
0
 
Simon BallCommented:
or, you could have a field on the form called empEmail, which is hidden, and who's value is as above... then reference that field in the macro.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
Boyd (HiTechCoach) Trimmell, Microsoft Access MVPCommented:
The correct way to work with the Hyperlink data type and parse out the parts is to use the HyperlinkPart method.

See:  HyperlinkPart Method and HyperlinkPart Method


0
 
CherylecAuthor Commented:
Sudonim
When I try and convert the macros to VB, I get an error"there was a problem converting the macros, do you want to continue, I click yes but it just does the same thing and doesn't convert anything
any suggestions?
I have the form open in design view and click on the convert to vb icon int he design ribbon

TheHiTehcoach: I will research your papers as well, I would like both functions to work
0
 
Boyd (HiTechCoach) Trimmell, Microsoft Access MVPCommented:
Cherylec,

<<When I try and convert the macros to VB, I get an error"there was a problem converting the macros, do you want to continue, I click yes but it just does the same thing and doesn't convert anything
any suggestions?>>

Well, that caused it is a bug in Access 2010. I believe it was fixed with the SP! update. But the SP1 update has other issues.

There is not problem doing what you what, at least with VBA code. I rarely use Macros. The Macros design has been greatly improved in Access 2010 for amking Web Databases.


0
 
Boyd (HiTechCoach) Trimmell, Microsoft Access MVPCommented:

Here is the VBA code to use in a commnd button's On CLick Event

Private Sub Command234_Click()

' the following line prints to the Immediate Window (ctrl-g) 
     Debug.Print HyperlinkPart(Me.txtEmailAsHyperLink, acAddress)

' Create an Email
     Application.FollowHyperlink HyperlinkPart(Me.txtEmailAsHyperLink, acAddress)

End Sub

Open in new window


*** Change Me.txtEmailAsHyperLink to match for control's name


FWIW: I find it best to not use the hyperlink data type for email address.
0
 
CherylecAuthor Commented:
Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now