Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Interactively change table and control source
Message
 
To
06/07/2006 05:35:19
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01134064
Message ID:
01134069
Views:
16
>Hi Boris,
>The table structure of all the tables are EXACTLY the same. So please tell me
>how to do it. Thank you.
>
>regards
>
>
>Syan H

1. If tables are small:

I would create a cursor in Init event of the form with structure as the tables you select.
Bound all controls to that cursor.
There where you want to change control sources:
SELECT MyCursor
ZAP
INSERT INTO MyCursor SELECT .... FROM NewTable
thisform.Refresh()
That way you don't need to change anything.

2. If tables are BIG:
There where you want to change ControlSource:
thisform.ChangeSource(NULL)
USE IN OldTable
SELECT 0
USE NewTable
thisform.ChangeSource([NewTableName])



*** thisform.ChangeSource()
   LPARAMETERS lcTableName
   FOR EACH oControl IN thisform.Controls
       IF UPPER(oControl.BaseClass) == [TEXTBOX]
          IF ISNULL(lcTableName)
             *** Save old ControlSource in TAG property of TextBox
             oControl.Tag           = oControl.ControlSource

             *** Set ControlSource to NULL, so it wont complains when we close Table
             oControl.ControlSource = NULL
          ELSE

             *** Set ControlSource to NewTable, and field name we get from TAG
             oControl.ControlSource = lcTableName+[.]+JUSTEXT(oControl.Tag)
          ENDIF
       ENDIF
   NEXT
(not tested)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform