What's wrong with the syntaz of this statement?

F

Fred

Well, here's the short version of my quesion: (the long version follows)

What's wrong with the syntaz of this statement? (and could you tell me how
to fix)

Set rec_mail = CurrentDb.OpenRecordset("select * from people",
dbopendynaset)

Thank you in advance for your much-needed assistance!

Sincerely,

Fred

The long version is the following exchange / sequence:


I asked the folowing question:

Re: Concentating contents from multiple records into one stored string in

I'm very experienced at Access/DB's but figure me as a absolute absolute
complete novice on using code, to the point that I don't even know if this is
a code (vs. query etc.) question.

Let's say that I have a "People" table, with 20 records in it and one of the
fields in it is "EmailAddress". Every record always has a valid
EmailAddress.

I want to concentate all 20 of the emails into (separated by commas) a text
string and store it somewhere (preferably a memo field, but a text document
would also be OK) which can then do a dummy level copy (onto the clipboard)
of the string and paste into the "to" line when writing an email (in a
software [e.g. Thunderbird] that wants comma delimiters.)

Could you tell me how to do this, keeping my first sentence in mind?

Thank you very much in advance for any help that you can give me!!

Sincerely,

Fred

And Paolo was kind enough to answer with:

if I've understood well your question create a button and add this code to
the on click event

Dim rec_mail As DAO.Recordset
Dim str_mail As String * 32000

Set rec_mail = CurrentDb.OpenRecordset("select * from people",
dbopendynaset)
tmp_mail = ""
Do While Not rec_mail.EOF
tmp_mail = tmp_mail & rec_mail!emailaddress & ","
rec_mail.MoveNext
Loop
str_mail = Left(Left(tmp_mail, Len(tmp_mail) - 1) & Space(32000), 32000)
file_num = FreeFile
Open "c:\email.txt" For Random As #file_num Len = 32000
Put #file_num, , str_mail
Close #file_num
rec_mail.close


I tried that and it errored out, said that there is a syntax error in

Set rec_mail = CurrentDb.OpenRecordset("select * from people",
dbopendynaset)
 
D

Douglas J. Steele

Dirk Goldgar responded to your first post over an hour ago. Please read his
answer. If you have questions, post them as a followup to that thread,
rather than starting a new thread.
 
F

Fred

Doug,

Somehow this web site put my followup question in a position older than my
original question and so I didn't see it and thought it never got posted.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top