
DataGrid "Column Not Found" error
I'm running VB6, ADO to Jet 4.0, and have a grid bound to a
datasource. Now I add an extra column, unbound, programatically with
DataGrid.Columns.Add(index) and it appears to work when I run a
report. The new column is visible. I even can set the Caption for the
new column and it appears in the column heading in the report. All
appears fine until I try to put some data in the cells for the new
columm. At runtime, as soon as my code tries to add Values to the
cells I get a "Column not Found" error. I try typing some data in the
cells and I get the same error when I hit Enter. Is the column R/O
somehow?
Grid properties:
1. Visible=True
2. Enabled=True
3. Allow Update = True
4. Allow Delete = True
5. Allow Add New = True
The code:
Dim ColumnCount As Integer
ColumnCount = grdReportsGrid.Columns.Count
grdReportsGrid.Columns.Add (ColumnCount)
grdReportsGrid.Columns(ColumnCount).Caption = "Total"
grdReportsGrid.Columns(ColumnCount).Locked = False
grdReportsGrid.Columns(ColumnCount).Visible = True
For i = 0 To grdReportsGrid.ApproxCount - 1
grdReportsGrid.Row = 0 + i
Sum = Sum + grdReportsGrid.Columns(0).Value
grdReportsGrid.Columns(ColumnCount).Value = Sum <-------bombs
here
Next
When I step through this I see that "Sum" has the correct value, and
(ColumnCount) has the correct value (an index of 4 for a fith column.)
Thanks for any help you can give me. Paul