Ben McCall
Registered User.
- Local time
- Today, 22:53
- Joined
- Jun 20, 2001
- Messages
- 22
I have a database in access 97.
I have one table – “report” which contains two fields – “formatted answer” and “answer” in each record. I want to have a report that concatenates these fields sequentially on a line:
[formatted answer] & “ “ & [answer] for each record with a space between each concatenated record.
I am using the following code in the “On Format” event of the detail section of the report:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim db As Database
Dim rs As Recordset
Dim str As String
Set db = CurrentDb
Set rs = db.OpenRecordset("report", dbOpenTable)
rs.MoveFirst
Do Until rs.eof
str = str & rs![formatted answer] & " " & rs![answer] & ". "
rs.MoveNext
[Text2] = Trim(str) 'Text2 is unbound text box in detail.
Loop
rs.Close
Set rs = Nothing
End Sub
This gives me exactly what I want except that it goes through the loop for the number of records I have in the table. If I have four records it give me four concatenated lines on the report.
Can anyone tell me how to have this loop only one time no many how many record the table contains?
Thanks!
Ben McCall
[This message has been edited by Ben McCall (edited 07-07-2001).]
I have one table – “report” which contains two fields – “formatted answer” and “answer” in each record. I want to have a report that concatenates these fields sequentially on a line:
[formatted answer] & “ “ & [answer] for each record with a space between each concatenated record.
I am using the following code in the “On Format” event of the detail section of the report:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim db As Database
Dim rs As Recordset
Dim str As String
Set db = CurrentDb
Set rs = db.OpenRecordset("report", dbOpenTable)
rs.MoveFirst
Do Until rs.eof
str = str & rs![formatted answer] & " " & rs![answer] & ". "
rs.MoveNext
[Text2] = Trim(str) 'Text2 is unbound text box in detail.
Loop
rs.Close
Set rs = Nothing
End Sub
This gives me exactly what I want except that it goes through the loop for the number of records I have in the table. If I have four records it give me four concatenated lines on the report.
Can anyone tell me how to have this loop only one time no many how many record the table contains?
Thanks!
Ben McCall
[This message has been edited by Ben McCall (edited 07-07-2001).]