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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Mailto:" Hyperlink 1

Status
Not open for further replies.

cstuart79

Technical User
Nov 2, 2009
171
US

well, i got the mailto: functionality to work as far as opening up a new message upon double clicking, but i cannot seem to figure out how to have the To: populated with the unique email address?
i am putting the code in the double click event of the field on a continuous form. as i have thousands of addresses i can't feasibly write out a code

application.followhyperlink "mailto:" & "cstuart@yahoo.com"

for each!
 
ugh. this is like coming into the middle of a conversation and having no idea what is going on.

afraid i've never used the "hyperlink mailto" functionality. (i would just create an instance of outlook and have it mail that way)

but either way: create a recordset with the addresses and have it loop thru the recordset.
Know how to do that?
 
sorry to bring you in the middle of a conversation! i wanted to create double-click feature on hyperlink instead of single click so i had to change "hyperlink" to text and enter code into double-click event on field in order to use this functionality. this has enabled me to open up a new message upon double-clicking, but the problem is getting the email address in the mailto: field without having to make each unique. i like your idea of using a recordset but am not sure how this works. can you give me some details?
 
So are you creating a string of addresses to mail to? or....

Create a query where you return just the ADDRESS Field (i'll call it AddName) for those addresses you want to use.
Copy the sql and :

Dim db as database
Dim rs as recordset
Dim qdf as querydef
dim strSql as string
Dim strName as string

set db = currentdb()
strSql = "the sql that you copied above"
set qdf = db.CreateQueryDef("", strSql)
set rs = qdf.OpenRecordset(dbOpenDynaset)

If rs.RecordCount > 0 Then
rs.MoveFirst
Do While Not rs.EOF
If Not IsNull(rs!AddName) Then
strname = rs!AddName
'USUALLY YOU ADD YOUR CODE HERE ON WHAT YOU WANT IT TO DO WITH THE STRNAME. besure to enclose it in quotes if needbe like "'" & strname & "'"

End if
rs.movenext
loop
End if

rs.close
qdf.close
set rs=nothing
set qdf=nothing
set db =nothing


============
again i don't know how one would use that hyperlink field, especially with multiple addresses let me know if you'd rather just use outlook and email when someone clicks a button.
 
all i'm trying to do is have the capability of double-clicking on a single email address and having that address in the "to:" field of a new outlook message. i was able to figure out how to do this with a single click, but then i cannot copy/paste an address without opening up a new message. therefore, i wanted to use double-click. since this option is not available from table database view, i changed the address back to text rather than hyperlink and entered vb code (application.followhyperlink "mailto:" & "cstuart@yahoo.com") in double-click event which works perfectly. the only problem is that instead of entering each unique address "cstuart@yahoo.com" i want to edit the vb code so that it populates the "mailto:" with whatever is in the field that was clicked. help!
 
in the do

Dim strAddress as string
strAddress = FieldName.value
application.followhyperlink "mailto:" & "'" & strAddress & "'"

 
first sentence was supposed to be

in the double-click event: (instead of 'in the do')
 
applied this code:

Private Sub Email__1_DblClick(Cancel As Integer)
Dim strAddress As String
strAddress = FieldName.Value
Application.FollowHyperlink "mailto:" & ""&strAddress&""
End Sub

got this Compile error:

Syntax error

what am i doing wrong?
 
you have to replace "fieldname" with the name of your control that has the EMAIL ADDRESS value in it.
 
GEESH!

make that: Me!Controlname.value
and replace the controlname with the name of your control.

SO:

Dim strAddress as string
strAddress= Me!ControlName.value
application.followhyperlink "mailto:" & "'" & strAddress & "'"


 
applied this code:

Private Sub Email__1_DblClick(Cancel As Integer)
Dim strAddress As String
strAddress = Me.Email__1.Value
Application.FollowHyperlink "mailto:" & ""&strAddress&""
End Sub


got this error:
The expression On Dbl Click you entered as the event property setting produced the following error: Syntax error.
*The expression may not result in the name of a macro, the aname of a user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or macro.
 
& ""&strAddress&""

should be: "'" & strAddress & "'"

(it is NOT just two quotes like this: ""
...it is a single quote enclosed by a quote on each side: "'") on both sides of & strAddress &

once you fix that...
and if it fails,
Can you step thru it and see what line it is failing on?
(put a breakpoint on strAddress= line and run it line by line.)


 
IT WORKED!!! thank goodness. i appreciate all of your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top