General information
Category:
Forms & Form designer
Title:
Changing the DBC and reloading a form
I have a form based on a class. When it loads, the beforeopentables database event calls the following method:
PRIVATE ALL LIKE l_*
SET TALK OFF
SET EXCL OFF
IF TYPE( 'oApp' ) = 'O'
l_cdata = SYS(5) + CURDIR() + oapp.cdatabase + '.dbc'
ELSE
l_cdata = SYS(5) + CURDIR() + 'data_testdata\wedding.dbc'
ENDIF
SET DATA TO ( l_cdata )
l_lOk = .T.
l_nx = 0
DO WHILE l_lOk
l_nx = l_nx + 1
l_cObject = 'thisform.dataenvironment.cursor' + TRANSF( l_nx )
IF TYPE ( l_cObject ) = 'O'
WITH &l_cObject
IF NOT ( 'common' $ LOWER( .DATABASE ) )
.DATABASE = l_cdata
ENDIF
ENDWITH
ELSE
l_lOk = .F.
ENDIF
ENDDO
This will set all the cursors in the DE to the proper database. When I actually get the form open I can see that indeed the proper tables have been opened.
However, if I have loaded the form multiple times and switched the databases in between, when I requery the views for the form, the views are pointing to a previous DBC.
The paths are set correctly, and the DBC() is set correctly. I know there is an issue with VFP caching objects, but I don't know if this has anything to do with my symptoms. I believe from time to time, this code has worked for me.
Anyone have suggestions?
Thanks.
Dave
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