SleepingGiant
Programmer
I'm having difficulty inserting a record from one inventory table to a structurally identical table if it does not exist. Both tables have 6 columns, "ID", "Description", "Average Cost", "Amount", "Vendor" and "VenStockNo." I have managed to get it to locate and add the "amount" (quantity) from one to the other if it does exist, however, I can't seem to get it to insert a record to add new items if it doesn't exist. Here's what I have so far...
method DoReportD(Print Logical)
var
TC1, TC2 TCursor
endVar
if TC1.open(":WORKefctWSE.DB" and
TC2.open("RIV:!DfctWse.DB" then
TC1.edit()
IF TC1.Locate ("ID", TC2."ID" then
TC1."Amount" = TC1."Amount"+TC2."Amount"
TC1.endEdit()
endif
IF NOT TC1.Locate ("ID", TC2."ID" then
TC1.InsertRecord()
TC1."ID"=TC2."ID"
TC1."Description"=TC2."Description"
TC1."Average Cost"=TC2."Average Cost"
TC1."Amount"=TC2."Amount"
TC1."Vendor"=TC2."Vendor"
TC1."VenStockNo"=TC2."VenStockNo"
endIf
TC1.endEdit()
TC1.close()
TC2.close()
endIf
endmethod
Any help is appreciated. TIA
method DoReportD(Print Logical)
var
TC1, TC2 TCursor
endVar
if TC1.open(":WORKefctWSE.DB" and
TC2.open("RIV:!DfctWse.DB" then
TC1.edit()
IF TC1.Locate ("ID", TC2."ID" then
TC1."Amount" = TC1."Amount"+TC2."Amount"
TC1.endEdit()
endif
IF NOT TC1.Locate ("ID", TC2."ID" then
TC1.InsertRecord()
TC1."ID"=TC2."ID"
TC1."Description"=TC2."Description"
TC1."Average Cost"=TC2."Average Cost"
TC1."Amount"=TC2."Amount"
TC1."Vendor"=TC2."Vendor"
TC1."VenStockNo"=TC2."VenStockNo"
endIf
TC1.endEdit()
TC1.close()
TC2.close()
endIf
endmethod
Any help is appreciated. TIA