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

concatenating records to one text file

Status
Not open for further replies.

robmkimmons

Technical User
Jun 29, 2001
51
0
0
US
Hi,

I have records of all my customers' email addresses. I want to export those records into a text file with all of the fields combined and seperated by a ";" so that the text field can be copied and pasted into a mass email.

Thanks

[b][COLOR=blue]~Rob[/b][/color]

[COLOR=red]If we expect the unexpected, does that make the unexpected... well, expected? [/color]
 
I trust you aren't doing this so that every customer can see the email address of every other customer.

I would do this the easy way be copying and pasting into Word. Then do a search and replace in Word to get the format correct.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
If the Email Address are all in one table you can extract them into one text variable.

Example code.

Dim dbs As Database, rst As DAO.Recordset
Dim strEmailAddress As String

Set dbs = CurrentDb 'Referance the current database
Set rst = dbs.OpenRecordset("YourTableName") ' referance the table

strEmail = ""
If Not rst.EOF Then rst.MoveFirst
Do Until rst.EOF 'Loop start
With rst
strEmailAddress = strEmailAddress & !NameOfEmailField & "; "
rst.MoveNext
End With
Loop ' Loop End
rst.Close ' the refence table
Set dbs = Nothing ' close the referance database

The strEmailAddress now equals "EmailFromRec1@hotmail.com; EmailfromRec2@other.com;" etc... So now you can send you Email. The SendObject function creates an Email using your Email program like Outlook Express. It will open your email program, create the email, insert the strEmailAddress into the "Send To" and because of the True parameter in the SendObject function, the Email is NOT automaticly sent, so you can edit the email before sending it.

' Send Email
DoCmd.SendObject , "", "",strEmailAddress , "", "", "YourEamilSubject", "MessageText", True, ""


Dalain
 
There is actually a generic function to concatenate in faq701-4233.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top