>I have a grid on a form that has a handful of columns. Through code, I then add additional columns as follows ...
>
>- Create a temporary cursor for this column
>- set the relationship to the grid's control source
>- Use AddColumn() to add a column with a control source that references the temporary cursor
>- Refresh the Grid
>
>This all functions wonderfully. The problem is when I want to delete one of the columns connected to a temporary cursor. What I have tried is ...
>
>- Use DeleteColumn() to remove the column
>- Close the temporary cursor
>- Refresh the grid
>
>What happens is that all the columns from the grid disappear as if they are connected to invalid control sources. If I comment out the line of code that closes the temporary cursor, everything works fine. The one column I want to delete disappears and the rest remain. But now I have an extra cursor hanging around that I don't need.
>
>I can't figure out why closing the temporary cursor would break the rest of the grid. The only column in the grid that references the temporary cursor is the one I just deleted with DeleteColumn().
Cathy,
You could do it like this safely :
with myGrid
.DeleteColumn(lnIndex1)
.DeleteColumn(lnIndex2)
.DeleteColumn(lnIndex3)
lcRecordSource = .recordsource
.recordsource = ""
Use in "myCursor"
.recordsource = lcRecordSource
endwith
Cetin