Re: database - table references (VFP9)
- From: trw7at@xxxxxxxxxxxxxxxxxx (Tim Witort)
- Date: Wed, 15 Jun 2005 17:44:43 GMT
Michael S. Jensen seemed to utter in
news:e0p2PmRcFHA.2180@xxxxxxxxxxxxxxxxxxxx:
> Sure did - damn,
>
> Even AutoOpenTables=.F. followed by a manual call to OpenTables does
> not help much.
>
> It would have, if the data environments init method was called before
> any of the other controls init method - but no :-(
I (and many others, I'm sure) have had a pretty simple solution to
this for many years...
In your base form class, add a method whose purpose is to change
the database property of all the cursors in the DE. Call it
something like FixCursorDBs or something. It should look like this
(forgive any wrapping):
LOCAL toForm, tuDBCs, lnCursCount
*
* Make sure DELETED is set ON:
*
SET DELETED ON
*
* tuDBCs is the full path to the current DBC that you actually
* want the cursors to point to:
*
toForm = This
tuDBCs = ALLTRIM(goApp.curDBPath)+"MYDB.DBC"
*
* Only do this on forms:
*
IF type("toForm.BaseClass") = "C" ;
AND upper(alltrim(toForm.BaseClass)) = "FORM"
ELSE
return .f.
ENDIF
*
* loop thru toForm.DataEnvironment and update each Cursor.Database
*
lnCursCount = 0
local lnCount, loObject
local array laDEMembers[1]
IF amembers(laDEMembers,toForm.DataEnvironment,2) > 0
FOR lnCount = 1 to alen(laDEMembers,1)
loObject = eval("toForm.DataEnvironment."+laDEMembers[lnCount])
IF upper(alltrim(loObject.BaseClass)) == "CURSOR"
IF UPPER(JUSTFNAME(loObject.Database)) == UPPER(JUSTFNAME
(tuDBCs))
loObject.Database = tuDBCs
ENDIF
ENDIF && we've hit a cursor
ENDFOR
ENDIF
return .t.
Then, in each form you create, add the following method call to
the BeforeOpenTables method of your form's DE:
FixCursorDBs()
That's it. All of the cursors in your DE will correctly point
to the database that is identified (in this case) by the
goApp.curDBPath property.
-- TRW
_______________________________________
t r w 7
at
i x dot n e t c o m dot c o m
_______________________________________
.
- Follow-Ups:
- Re: database - table references (VFP9)
- From: Michael S. Jensen
- Re: database - table references (VFP9)
- From: Michael S. Jensen
- Re: database - table references (VFP9)
- References:
- database - table references (VFP9)
- From: Michael S. Jensen
- Re: database - table references (VFP9)
- From: Michael S. Jensen
- Re: database - table references (VFP9)
- From: Paul Pedersen
- Re: database - table references (VFP9)
- From: Michael S. Jensen
- database - table references (VFP9)
- Prev by Date: Re: Adding cell borders in Excel through VFP7
- Next by Date: Remote View & Sql2000
- Previous by thread: Re: database - table references (VFP9)
- Next by thread: Re: database - table references (VFP9)
- Index(es):