Reputation: 31
I just started working with FoxPro at school and I have a few problems when I try to create a form that needs to add data to muliple tables (no designer).
I am using the APPEND command but this seems to add data only to the main table.
Any suggestions for a solution are greatly appreciated.
Thanks
Upvotes: 3
Views: 2423
Reputation: 48139
You need to explicitly select the work area (alias or table) before doing an append. For example, in your "CLICK" event you would do something like...
SELECT FirstTableName
append blank
replace FieldW with "something",;
FieldX with 1.23,;
FieldY with SomeVariable,;
FieldZ with Thisform.SomeTextbox.Value
SELECT SecondTableOrAlias
append blank
replace FieldA with Thisform.AnotherTextbox.Value,;
FieldB with Thisform.SomeCheckBox.Value
SELECT ThirdTableOrAlias
append blank
replace ...
If the tables are NOT already opened from the form's DataEnvironment, you might want to ensure they are open first by doing the following BEFORE the above Append/Replace
if not used( "FirstTableName" )
select 0
use FirstTableName
ENDIF
if not used( "SecondTableOrAlias")
select 0
use SecondTableOrAlias
endif
etc...
Additionally, VFP DOES support SQL too, so you could do
insert into FirstTableName ;
( FieldW,;
FieldX,;
FieldY,;
FieldZ ;
);
values ;
( "something",;
1.23,;
SomeVariable,;
Thisform.SomeTextbox.Value ;
)
And to query data out via SQL-Select
select * from FirstTableName ;
where FieldW = "something" ;
into cursor C_SomeTempResultSet READWRITE
Upvotes: 3