mohammadagul
PrinceAtif
- Local time
- Today, 12:48
- Joined
- Mar 14, 2004
- Messages
- 298
hello friend
i got the following code from a download on this site. basically what is does it concatenates the field "Medication" with itesef if the Clinet id is Same.
the only problem is that it concatenates all records except the last record.
Please help me with this
Option Compare Database
Public Sub s_runMe()
Dim cn As ADODB.Connection
Dim rs1 As ADODB.Recordset
Dim rs2 As ADODB.Recordset
Set cn = CurrentProject.Connection
Set rs1 = New ADODB.Recordset
Set rs2 = New ADODB.Recordset
rs1.Open "query1", cn, adOpenDynamic, adLockOptimistic
rs2.Open "tempMedications", cn, adOpenDynamic, adLockOptimistic
rs1.MoveFirst
rs2.AddNew
rs2![client id] = rs1![client id]
rs2![med description] = rs1![med description]
rs1.MoveNext
Do While Not rs1.EOF
If rs1![client id] = rs2![client id] Then
rs2![med description] = rs2![med description] & ", " & rs1![med description]
Else
rs2.AddNew
rs2![client id] = rs1![client id]
rs2![med description] = rs1![med description]
End If
rs1.MoveNext
Loop
rs1.Close
MsgBox "Done (KenHigg is so smart!)"
End Sub
i got the following code from a download on this site. basically what is does it concatenates the field "Medication" with itesef if the Clinet id is Same.
the only problem is that it concatenates all records except the last record.
Please help me with this
Option Compare Database
Public Sub s_runMe()
Dim cn As ADODB.Connection
Dim rs1 As ADODB.Recordset
Dim rs2 As ADODB.Recordset
Set cn = CurrentProject.Connection
Set rs1 = New ADODB.Recordset
Set rs2 = New ADODB.Recordset
rs1.Open "query1", cn, adOpenDynamic, adLockOptimistic
rs2.Open "tempMedications", cn, adOpenDynamic, adLockOptimistic
rs1.MoveFirst
rs2.AddNew
rs2![client id] = rs1![client id]
rs2![med description] = rs1![med description]
rs1.MoveNext
Do While Not rs1.EOF
If rs1![client id] = rs2![client id] Then
rs2![med description] = rs2![med description] & ", " & rs1![med description]
Else
rs2.AddNew
rs2![client id] = rs1![client id]
rs2![med description] = rs1![med description]
End If
rs1.MoveNext
Loop
rs1.Close
MsgBox "Done (KenHigg is so smart!)"
End Sub