Combine records in a table

S

slickdock

I have a temp table with ONE field: RecipientName.
I would like to get that information over to MSWord as one chunk of
information, so WOrd sees it as one record, with each Recipient Name
separated by a hard return, instead of a record break.
 
D

David H

You'll probably have to loop through each record, grab the value and add it
to a string.

What exactly are you trying to accomplish?
 
S

slickdock

I'm trying to insert a list into a Word merge file that otherwise has a
different data source. This "list" will be called by an {IncludeText} field
command in my Word form file.
Your idea sounds good. How can I loop, grab, and add to string?
 
J

Jack Leach

Function GetDataToString() As String

Dim Ret As String
Dim rs as DAO.Recordset

Set rs = CurrentDb.OpenRecordset("tablename")
Ret = ""

If rs.Recordcount <> 0 Then
rs.MoveFirst
While Not rs.EOF
Ret = Ret & rs(0)
rs.MoveNext
Wend
End If

rs.Close
Set rs = Nothing

GetDataToString = Ret
End Function




hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
D

David H

Is it a memo that your working?


slickdock said:
I'm trying to insert a list into a Word merge file that otherwise has a
different data source. This "list" will be called by an {IncludeText} field
command in my Word form file.
Your idea sounds good. How can I loop, grab, and add to string?
 
S

slickdock

OK, since I'm a total VB doofus, I copied and pasted your code into a module.
I made a macro that says RunCode GetDataToString().
Don't laugh, but now what? How do I see the results? Can I store the results
in a field in a query, for example, since that query is going to be the
data.txt file for my MSWord merge doc?
 

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