Using MySQL 5.1 on Windows 7 Home Premium, VFP SP2
DataEnvironment (DE) CursorAdapter (CA)
1. Build Form 1, use Form 1 DE, Table 1 in form DE as CA. Grid works fine.
2. Build Form 2, use Form 2 DE, Table 2 in form DE as CA. Grid works fine.
3. Build Form 3, use Form 3 DE, Table 1 in form DE as CA. Grid works fine.
Problem starts here:
Add Table 2 as CA to Form 3 above, place in 2 separate grids, not related.
Form won't run - Error message says:
Error loading file - record number 15. grdCursor2 <or one of its members>. ControlSource : Alias 'Cursor2' is not found.
Multiple attempts, same results - record number may vary.
I discarded the forms & re-started VFP to avoid any potential residual problem after every effort, etc.
No other classes or other code running, just the form.
So I tried a few other things.
4. Build Form 3, use Form 3 DE, Table 1 and Table 2 in form DE as CA's.
Only placed one grid based on Table 1 CA on on the form. Runs fine.
5. Removed grid based on Table 1 CA, placed grid based on Table 2 CA on the form.
Form won't run, similar error message.
6. Removed the Table 1 CA from the form DE, placed grid based on Table 2 on form.
Runs fine.
I have figured out a few more things.
I determined that using the DE to configure the connection.
If I do ALL connection configuration (carefully !) in each cursor, no problem.
So I can use CA's now. Just can't touch the DE.
But they are just so intimately involved.
And this will cause me more problems down the road until I figure out how to work it. I had planned to develop a DE class that would include CA's.
I came across this:
(from What's New in Visual FoxPro 8, page 134)
For a CursorAdapter instantiated in code, the Init event fires before all others, as you'd expect.
But for a CursorAdapter in the DataEnvironment of a form, the event order is different:
Event Order For a CursorAdapter in the DataEnvironment of a form:
DataEnvironment.OpenTables */* Is this right, does DataEnvironment.OpenTables fire before DataEnvironment.BeforeOpenTables ?
DataEnvironment.BeforeOpenTables */* OR should this line read as CursorAdapter.BeforeOpenTables ?
CursorAdapter.AutoOpen
CursorAdapter.BeforeCursorFill
CursorAdapter.CursorFill
CursorAdapter.AfterCursorFill
CursorAdapter.Init
DataEnvironment.Init
Thanks,
Chuck