Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding table contents to another

Status
Not open for further replies.

bobsmallwood

Programmer
Aug 9, 2001
38
US
I have code on a pushbutton that creates three identically structured tables in the PRIV directory. I would like to add code that appends the records of second to the first and then the third to the first so that all records are in the first table. Any ideas will be appreciated.
 
If the tables have the same structure it's easy to do using add(), below is the sample code from the help file. I think it's a lousy example but you should be able to get the idea.


method pushButton(var eventInfo Event)
var
newCust Query
ansTbl Table
destTbl String
endVar
destTbl = "Customer.db"

newCust.readFromFile("newCust.qbe")

if newCust.executeQBE() then ; if the query succeeds
ansTbl.attach(":pRIV:Answer.db")

; attempt to add Answer.db records to Customer.db
if isTable(destTbl) then
if NOT ansTbl.add(destTbl) then
errorShow()
endIf
else
msgStop("Error", "Can't find " + destTbl + ".")
endIf
else
errorShow("Query failed.")
endIf

endMethod
 
Thanks for the input. It worked, "almost". I got this error message: "Destination must be indexed". An indexed destination table is not required when manually adding the records of a source table to a destination table...at least not when the option is to append, which is what I want to do. Any further suggestions?

Thanks
 
No problem, set append to True and update to False, by default both are set to true and an indexed table is required for the update.


source.add("destination", True, False)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top