General information
Category:
Forms & Form designer
>I have forms with tables in their Dataenvironment.
>At form design time, VFP stores relative path of those cursors into cursor CursorSource. property
>
>I need to change CursorSource property because at run-time, files are at different locations.
>The only reasonable place to do it seems to be BeforeOpentables event.
>However, it is not possible to loop through cursors: dataenvironment does not have objects collection and cursor object names are changed.
Here is a way to achieve kind of what you want in the form LOAD event.
If allows you to walk down the cursor tree using AMEMBERS.
You can then experiment with setting the various values of each
cursor property.
loData = THISFORM.DataEnvironment
lnCursorCount =AMEMBERS( laCursor , loData , 2 )
IF loData.AutoOpenTables = .T.
MESSAGEBOX("Please set form to AUTOOPENTABLES = .F." )
RETURN .F.
ENDIF
***************************************************************************
*&& If there are no cursors in the class dont go any further
***************************************************************************
IF lnCursorCount = 0
lvReturn = loData.OpenTables()
&& FIRE OPENTABLES EVENT TO SYNC DATAENVIRONMENT
RETURN .T.
ENDIF
FOR lnCount = 1 TO lnCursorCount
loCursor = GETPEM ( loData , laCursor(lnCount) )
lcBuffer = loCursor.database
&& YOU NOW HAVE A POINTER TO THE CURSOR AND CAN ALTER VARIOUS SETTINGS
loCursor = .NULL.
lcDatabase = ""
ENDFOR
&& FIRE OPEN TABLES MANUALLY
lvReturn = loData.OpenTables()
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