I have a table [DailyUpdates] with thousands of record entries, usually the user searches this table through SearchForm resulting into some recordset. What I need to do on this recordset is to concatenate the contents of all the records for one field-[Description], and populate the resulting into textbox [FaultComms] of a form [UpdateSummary]
Expand|Select|Wrap|Line Numbers
- Private Sub Form_Load()
- Dim db As Database
- Dim rstUpdates As Recordset
- Set db = CurrentDb
- Set rstUpdates = db.OpenRecordset("Daily Fault Update", dbOpenDynaset)
- If Not rstUpdates.EOF Then rstUpdates.MoveFirst
- Do While Not rstUpdates.EOF
- vntTempData = vntTempData & rstUpdates!Description
- rstUpdates.MoveNext
- Loop
- Me.FaultComms = vntTempData
- End Sub
I tried to use filter property of recordset to limit the records and then open another recordset on it. The second sample of code!
Expand|Select|Wrap|Line Numbers
- Private Sub Form_Load()
- Dim db As Database
- Dim vntTempData as Variant
- Dim rstUpdates As Recordset
- Dim rstUpdates1 As Recordset
- Dim strOpen As String
- strOpen= "[TT_Number] =[Forms]![TXFaults].[TT_Number]"
- Set db = CurrentDb
- Set rstUpdates = db.OpenRecordset("Daily Fault Update", dbOpenDynaset)
- rstUpdates.Filter=strOpen
- Set rstUpdates1= rstUpdates.OpenRecordset
- If Not rstUpdates1.EOF Then rstUpdates1.MoveFirst
- Do While Not rstUpdates1.EOF
- vntTempData = vntTempData & rstUpdates1!Description
- rstUpdates1.MoveNext
- Loop
- Me.FaultComms = vntTempData
- End Sub
Expand|Select|Wrap|Line Numbers
- Set rstUpdates1= rstUpdates.OpenRecordset