It works fine with small data, but with hundreds of records it gets too slowly. I posted the following in "another place", but have not yet resolved this problem. Any assistance would be appreciated.
MD
I?ve created some code which is attached to a word document to do a compound merge. The database source is in an RTF file, and the first field (of 8 fields) in this document contains data from the ClientID autonumber field in my database. As there are a number of sub-records attached, each ClientID is repeated one or more times, in ascending order. The following code creates an array RS(i,x), where ?i? increments and ?x? is the count of each ClientID entry.
While the code works well for 20 ? 30 records, it takes a long time (70-80 secs.!) to loop through 256 records to create the array. It starts off quickly enough, but slows down exponentially as it progresses (running out of steam, I guess). Can someone suggest a quicker way to create the array. I don?t merge directly from the database because that is very much slower.
MD
'Create array of number of sub-records under each main record
Do
With ActiveDocument.MailMerge.DataSource
.ActiveRecord = wdNextRecord
If .ActiveRecord = Num Then GoTo ExitLoop
Num = .ActiveRecord
RecNo = ActiveDocument.MailMerge.DataSource.DataFields("ClientID").Value
If RecNo <> Tmp Then
i = i + 1
RS(i, 1) = i
RS(i, 2) = Num
Tmp = RecNo
End If
End With
Loop
ExitLoop:
MsgBox msg