Recordset ?

B

B

Hello all, I have a question on running a recordset and how do I grab all
the data in the recordset in respect to 1 column and I want it to
concatenate together instead of overwriting the variable.. here is my code
which just adds the current one back to the itself instead of the previous
column value

Private Sub Report_Open(Cancel As Integer)
Dim dbs As Database, rst As Recordset
Dim strSQL As String, Lgh As String, PC As String, LT As String
' Return reference to current database.
Set dbs = CurrentDb
strSQL = "SELECT * FROM LbrInv_PieceCount WHERE [Bundle_ID] = '" &
[Forms]![BundleEntryEdit]![BundleEntryEdit_subform].[Form]![Bundle_ID] & "'"
Set rst = dbs.OpenRecordset(strSQL)
Do While Not rst.EOF
Lgh = rst!Length_ID
LT = Lgh & " " & Lgh
PC = rst!Piece_Count
rst.MoveNext
Loop
Set dbs = Nothing
End Sub


also I have this running to on the report open should I instead be calling
this .. I eventually want the value returned to be on the report itself...
TIA
 
B

B

oh geez... thanks much. .serves me right for not paying attention
Ken Snell said:
Change this line:
LT = Lgh & " " & Lgh

to this:
LT = LT & " " & Lgh
--

Ken Snell
<MS ACCESS MVP>

B said:
Hello all, I have a question on running a recordset and how do I grab all
the data in the recordset in respect to 1 column and I want it to
concatenate together instead of overwriting the variable.. here is my code
which just adds the current one back to the itself instead of the previous
column value

Private Sub Report_Open(Cancel As Integer)
Dim dbs As Database, rst As Recordset
Dim strSQL As String, Lgh As String, PC As String, LT As String
' Return reference to current database.
Set dbs = CurrentDb
strSQL = "SELECT * FROM LbrInv_PieceCount WHERE [Bundle_ID] = '" &
[Forms]![BundleEntryEdit]![BundleEntryEdit_subform].[Form]![Bundle_ID] & "'"
Set rst = dbs.OpenRecordset(strSQL)
Do While Not rst.EOF
Lgh = rst!Length_ID
LT = Lgh & " " & Lgh
PC = rst!Piece_Count
rst.MoveNext
Loop
Set dbs = Nothing
End Sub


also I have this running to on the report open should I instead be calling
this .. I eventually want the value returned to be on the report itself...
TIA
 

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