General information
Category:
Forms & Form designer
>>If I then clear (ZAP) the table (on page on) and then
>>add a record to the table (so now there's only one
>>record in the table) and switch to page two the grid
>>shows that there are no records in the table.
>>
>>What's happening?
>
>Ok, I figured out what's happening but I still don't know
>how to fix it. In order to ZAP the table I must first
>open it exclusivly
>
>SELECT ProfileSrc
>
>lnOldBuffering = CURSORGETPROP( "Buffering", "ProfileSrc")
>USE (DBF()) EXCL
>
>ZAP it, and then re-open the file and set the properties
>
>USE (DBF()) ;
> ALIAS ProfileSrc
>CURSORSETPROP( "Buffering", lnOldBuffering, "ProfileSrc")
>
>Somewhere in this process the grid columns get destroyed.
>
>I discovered this because I use one of the cells in the
>grid to search for values in another table. After clearing
>ProfileSrc I get an "Unknown Member" error. Also when
>the grid is displayed it comes up totally blank with no
>headers or gridlines.
>
>Like I say, I know what's happening, but don't know how
>to fix it.
>
>Anyone???
>
> ...kt
probably more than you wanted to know but i have the exact same situation as you - needed to zap a file so had to open exclusive. i had an additional situation where one screen closed all the databases, did some processing and then reopened them. so i wrote a routine to save all the grid recordsources before i went to this process, and then restore the recordsources after i came back. i had to do more than the recordsources. i found i also had to record the controlsources (my grid did not show all fields in the table), and the columncount.
it probably count be a little slicker, but i a struggling vfp programmer.
GRID_SAVE_RECORDSOURCE
**** this routine saves the recordsource, number of columns, column control source for each grid.
**** if you are messing with the grid recordsource (like set and create view, delete and recreate
**** the file, eec) you need to set the recordsource = "" and
**** recordsourcetype = 0. when you are done messing with then recordsource, you need to restore
**** the recordsource, recordsourcetype, columncount, columns.controlsource.
****
**** probably should osdi.lockscreen = .t. before calling this and then
**** osdi.lockscreen = .f. after grid_restore_recordsource
**** to add a new grid or change an existing grid:
**** - add/change grid name in acon_gridname
**** - modify maxnumgrids (if adding or deleting grid)
PUBLIC agridname[1] aControlsource[2], arecordSource[1], acolumncount[1], numgrids
maxnumgrids = 5 && change 1 of 2 to add/delete grid
dimension agridname[maxnumgrids]
dimension aControlSource[maxnumgrids,50]
dimension arecordsource[maxnumgrids]
dimension acolumncount[maxnumgrids]
numgrids = 0
dimension acons_gridname[maxnumgrids] && change 2 of 2 to add/delete/change grid
acons_gridname(1) = "osdi.lotinv.grid1"
acons_gridname(2) = "osdi.equity.grid1"
acons_gridname(3) = "osdi.omainscr.page3.collat.grid1"
acons_gridname(4) = "osdi.omainscr.page6.draw1.draw1grid"
acons_gridname(5) = "osdi.omainscr.page6.draw2.draw2grid"
FOR gridnum = 1 to maxnumgrids
*** build the "gridname" (with the quotes)
gridname_quotes = '"'+acons_gridname(gridnum)+'"'
*** does it exist? is it not undefined?
if !(type(&gridname_quotes) == "U")
numgrids = numgrids + 1
*** save the grid's name
agridname(numgrids) = acons_gridname(gridnum)
*** save the grid's coluumn control source
FOR nCnt = 1 TO &agridname(numgrids)..ColumnCount
aControlsource(numgrids,nCnt) = &agridname(numgrids)..Columns(nCnt).ControlSource
ENDFOR
*** save the grids's recordsource
arecordsource(numgrids) = &agridname(numgrids)..recordsource
*** save the grids's columncount
acolumncount(numgrids) = &agridname(numgrids)..ColumnCount
*** set the grid's recordsource to space(0)
&agridname(numgrids)..recordsource = space(0)
*** set the grid's recordsourcetype to 0
&agridname(numgrids)..recordsourcetype=0
endif
endfor
GRID_RESTORE_ RECORDSOURCE
*** restore each grids recordsource, recordsourcetype, columncount and each columns controlsource
**** should probably osdi.lockscreen = .f. after this (if it was = .t. beofore grid_save_recordsource)
FOR gridnum = 1 to numgrids
&agridname(gridnum)..recordsourcetype = 1
&agridname(gridnum)..recordsource = arecordsource(gridnum)
&agridname(gridnum)..columncount = acolumncount(gridnum)
FOR nCnt = 1 TO acolumncount(gridnum)
&agridname(gridnum)..Columns(nCnt).ControlSource = aControlsource(gridnum,nCnt)
ENDFOR
&agridname..refresh()
endfor
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only