>>>>I need to close and reopen the data source (a cursor) for a grid without adversely affecting the grid.
>>>
Thisform.grid1.RecordSource = SPACE(0)
>>>* Create/recreate cursor
>>>...
>>>Thisform.grid1.RecordSource = "mycursor"
>>>Thanks for the quick response.
>>>
>>>When the cursor is refreshed, the grid is now showing all columns instead
>>>of a subset.
>>
>>You've to set recordsource of the grid to the empty string before you do anything to a cursor.
>
>This is what I am doing, here is the code from a text box VALID() that contains a new Order ID:
cCurrentRecordSource = This.Parent.Parent.pagDetails.grdOrDetails.RecordSource
>This.Parent.Parent.pagDetails.grdOrDetails.RecordSource = SPACE(0)
>
>SELECT * ;
> FROM OrDetail ;
> INTO CURSOR curCurrentOrder ;
> WHERE OrDetail.cOrder = cValue ;
> AND ALLTRIM(OrDetail.cOrder) IN (Select Drawings.cOrderID FROM Drawings) ;
> READWRITE
>
>This.Parent.Parent.pagDetails.grdOrDetails.RecordSource = cCurrentRecordSource
I've just discovered why the columns were being reset: The cursor was being created in the init event.
Now the column headings are correct, but the actual data displayed does not correspond to the headings.
More details:
I've discovered that the columns are displayed correctly if I view the Grid immediately. However when I set the ...grdOrDetails.RecordSource = Space(0) each column loses it's ControlSource.