Mailing

peterbowles

Registered User.
Local time
Today, 07:29
Joined
Oct 11, 2002
Messages
163
Hi

I want to press a button on a field and it pick up all the email address in table and put them in the TO: field of the email window
not very good at the code so any examples would be great

Thanks
 
Public Sub Email()

Dim rst as Recordset
Dim strTo as string
Dim strInsert as string

Set rst = CurrentDb.OpenRecordset("TableName",dbOpenDynaset)
strTo=""
strInsert="; "
rst.MoveFirst
Do Until rst.EOF
strTo=strTo & rst![Email Address Field] & strInsert
rst.MoveNext
Loop
Docmd.SendObject acSendNoObject, , , strTo

End Sub
 
Thanks for the code I put it in but can not get it to work

Public Sub email_Click()



Dim rst As Recordset
Dim strTo As String
Dim strInsert As String
Dim strTable As String
strTable = "EmailList"



Set rst = CurrentDb.OpenRecordset("strTable", dbOpenDynaset)

strTo = ""
strInsert = "; "
rst.MoveFirst
Do Until rst.EOF
strTo = strTo & rst![Email ] & strInsert
rst.MoveNext
Loop
DoCmd.SendObject acSendNoObject, , , strTo

End Sub

get an error that states invalid arguement on this line
Set rst = CurrentDb.OpenRecordset("strTable", dbOpenDynaset)
 
Set rst = CurrentDb.OpenRecordset("strTable", dbOpenDynaset)

That's correct except that since you've already setup strTable as a string it doesn't need to be in quotes. Just make it this:

Set rst = CurrentDb.OpenRecordset(strTable, dbOpenDynaset)
 

Users who are viewing this thread

Back
Top Bottom