planetdrouin
Technical User
My code correctly populates each of the unbound controls on the first record, but each subsequent record has the same data as the first. I am rather new to programming, so I am must be missing something rather simple (I hope).
My code looks like:
Private Sub Form_Load()
Dim intX As Integer, RowTotal As Long, db As DAO.Database, qdf As DAO.QueryDef, frm As Form, ColumnCount As Integer, rs As DAO.Recordset
Set db = CurrentDb
Set qdf = db.QueryDefs("QryAccountsExpenseDetail"
Set rs = qdf.OpenRecordset
ColumnCount = rs.Fields.Count
rs.MoveFirst
While Not rs.EOF
RowTotal = 0
For intX = 1 To ColumnCount
Me("Text" + Format(intX)) = Nz(rs(intX - 1), 0)
Me("Label" + Format(intX)).Caption = rs(intX - 1).Name
Next intX
Me("Label" + Format(ColumnCount + 1)).Caption = "Totals"
For intX = 3 To ColumnCount
RowTotal = RowTotal + Nz(rs(intX - 1), 0)
Me("Text" + Format(intX)).ColumnHidden = False
Next intX
For intX = (ColumnCount + 2) To TotalColumns
Me("Text" + Format(intX)).ColumnHidden = True
Me("Label" + Format(intX)).Visible = False
Next intX
' Place row total in text box
Me("Text" + Format(ColumnCount + 1)) = RowTotal
rs.MoveNext
Wend
End Sub
I thought that the rs.movenext would be sufficient, however I now realize it isn't. It moves to the next record in my recordset, but how do I move to the controls on the form of the next record.
I am using Access XP, and the first two columns of my data are Date and Transaction description. Any help would be greatly appreciated.
Lawrence
My code looks like:
Private Sub Form_Load()
Dim intX As Integer, RowTotal As Long, db As DAO.Database, qdf As DAO.QueryDef, frm As Form, ColumnCount As Integer, rs As DAO.Recordset
Set db = CurrentDb
Set qdf = db.QueryDefs("QryAccountsExpenseDetail"
Set rs = qdf.OpenRecordset
ColumnCount = rs.Fields.Count
rs.MoveFirst
While Not rs.EOF
RowTotal = 0
For intX = 1 To ColumnCount
Me("Text" + Format(intX)) = Nz(rs(intX - 1), 0)
Me("Label" + Format(intX)).Caption = rs(intX - 1).Name
Next intX
Me("Label" + Format(ColumnCount + 1)).Caption = "Totals"
For intX = 3 To ColumnCount
RowTotal = RowTotal + Nz(rs(intX - 1), 0)
Me("Text" + Format(intX)).ColumnHidden = False
Next intX
For intX = (ColumnCount + 2) To TotalColumns
Me("Text" + Format(intX)).ColumnHidden = True
Me("Label" + Format(intX)).Visible = False
Next intX
' Place row total in text box
Me("Text" + Format(ColumnCount + 1)) = RowTotal
rs.MoveNext
Wend
End Sub
I thought that the rs.movenext would be sufficient, however I now realize it isn't. It moves to the next record in my recordset, but how do I move to the controls on the form of the next record.
I am using Access XP, and the first two columns of my data are Date and Transaction description. Any help would be greatly appreciated.
Lawrence