Article ID: 139524
Article Last Modified on 2/10/2000
dbcName dbcTables[1] dbcViews[1] gaDataEnvironment[1]
* Obtain an object reference to the data environment of the form in
* the Forms Designer
=ASELOBJ(ThisForm.gaDataEnvironment,2)
* Ask the user which .dbc file should be used, cancel builder if none
ThisForm.dbcname = GETFILE("DBC", "Select Database", "Open")
IF EMPTY(thisForm.dbcName)
RETURN .F.
ENDIF
* Populate arrays with the names of tables and views
OPEN DATABASE (thisForm.DBCName)
lnTables=ADBOBJECTS(thisform.dbcTables,"TABLE")
ThisForm.LstTables.Requery
IF lnTables = 0
thisform.dbcTables(1,1) = "No Tables found"
thisform.LstTables.Enabled = .F.
ENDIF
lnViews=ADBOBJECTS(thisform.dbcViews,"VIEW")
ThisForm.LstViews.Requery
IF lnViews = 0
thisform.dbcViews(1,1) = "No Views found"
thisform.LstViews.Enabled = .F.
ENDIF
MultiSelect = .T. Name = LstTables RowSourceType = 5 (Array) RowSource = Thisform.dbcTables
MultiSelect = .T. Name = LstViews RowSourceType = 5 (Array) RowSource = Thisform.dbcViews
FOR iCnt = 1 TO THISForm.LstTables.ListCount
IF ThisForm.LstTables.Selected(iCnt)
lcName = PROPER(ThisForm.LstTables.ListItem(iCnt))
IF TYPE('ThisForm.aDataEnvironment(1).&lcname') != 'O'
ThisForm.gaDataEnvironment(1).AddObject(lcname, "Cursor")
WITH ThisForm.gaDataEnvironment(1).&lcname.
.Alias = lcname
.CursorSource = lcname
.Database = ThisForm.dbcName
ENDWITH
ENDIF
ENDIF
ENDFOR
FOR iCnt = 1 TO THISForm.LstViews.ListCount
IF ThisForm.LstViews.Selected(iCnt)
lcName = PROPER(ThisForm.LstViews.ListItem(iCnt))
IF TYPE('ThisForm.aDataEnvironment(1).&lcname') != 'O'
ThisForm.gaDataEnvironment(1).AddObject(lcname, "Cursor")
WITH ThisForm.gaDataEnvironment(1).&lcname.
.Alias = lcname
.CursorSource = lcname
.Database = ThisForm.dbcName
ENDWITH
ENDIF
ENDIF
ENDFOR
ThisForm.Release
ThisForm.Release
Additional query words: VFoxWin
Keywords: kbcode KB139524