Tuftco
asked on
VB6 DataGrid Going through Rows on Grid errors on last row
I have a bound Datagrid to an Access Db. In this particular case I get
an error when going through the rows to update a particular column.
The "resale" column is a hidden column. If I get a dataset with let's
say 9 rows, this will bomp out on the Datagrid1.Row when it i gets
to 8. This will udpate all rows except the last one. I have tried
For i = 1 To DataGrid1.ApproxCount -1
For i = 0 To DataGrid1.ApproxCount
For i =1 To DataGrid1.ApproxCount
For i = 0 To DataGrid1.ApproxCount - 1
DataGrid1.Row = i
DataGrid1.Columns("resale" ) = i
Debug.Print CStr(i) + " " + DataGrid1.Columns(0).Text
Next i
I have VB6 SP5 installed. Any help appreciated.
an error when going through the rows to update a particular column.
The "resale" column is a hidden column. If I get a dataset with let's
say 9 rows, this will bomp out on the Datagrid1.Row when it i gets
to 8. This will udpate all rows except the last one. I have tried
For i = 1 To DataGrid1.ApproxCount -1
For i = 0 To DataGrid1.ApproxCount
For i =1 To DataGrid1.ApproxCount
For i = 0 To DataGrid1.ApproxCount - 1
DataGrid1.Row = i
DataGrid1.Columns("resale"
Debug.Print CStr(i) + " " + DataGrid1.Columns(0).Text
Next i
I have VB6 SP5 installed. Any help appreciated.
ASKER
Either way, there is exactly 9 records to deal with in this case. What is getting me is that
the Datagrid seems to think that it has one less than what ever I return as a dataset.
the Datagrid seems to think that it has one less than what ever I return as a dataset.
Dim i As Long
For i = 0 To myRecordset.RecordCount - 1
'For i = 0 To Adodc1.Recordset.RecordCou nt - 1 'if you are using adoDC component use this line instead of prev one
DataGrid1.Row = i
DataGrid1.Columns("resale" ) = i
Debug.Print CStr(i) + " " + DataGrid1.Columns(0).Text
Next i
For i = 0 To myRecordset.RecordCount - 1
'For i = 0 To Adodc1.Recordset.RecordCou
DataGrid1.Row = i
DataGrid1.Columns("resale"
Debug.Print CStr(i) + " " + DataGrid1.Columns(0).Text
Next i
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
emoreau
Thank You for this answer. At first I didn't see why it works, but after a few trials I understand it.
I even used it go return to the top of the grid after going through the rows and updating
columns and making calculations..
GridGotoTop
With DataGrid1
.Row = 0
.Col = 0
End With
Thanks
Thank You for this answer. At first I didn't see why it works, but after a few trials I understand it.
I even used it go return to the top of the grid after going through the rows and updating
columns and making calculations..
GridGotoTop
With DataGrid1
.Row = 0
.Col = 0
End With
Thanks
Instead of .ApproxCount property use your recordset's .RecordCount property
Cheers!