I'm trying to append information to a table that is already in use by another user. Quite predictably I get an error message when trying to do this.....
Can anybody suggest a way that I can append a live table?
"append a live table". I believe what you mean is "to append records to a table in use by someone [else]". Assuming that ...
Assume that your tables have a single-field primary key called, for our purposes, "PK"
var
tcMyNewData tCursor
tcLiveTable tCursor
endVar
tcMyNewData.open(":Alias:MyNewData"
tcLiveTable.open(":Alias:LiveTable"
tcLiveTable.edit()
scan tcMyNewData :
tcLiveTable.setRange("PK", "PK"
if tcLiveTable.nRecords() < 1 then ;all-new record
tcLiveTable.insertRecord()
tcLiveTable.copyRecord(tcMyNewData)
tcLiveTable.postRecord()
else ;updating existing record
if tcLiveTable.recordStatus("Locked" = False then
tcLiveTable.copyRecord(tcMyNewData)
tcLiveTable.postRecord()
else ;someone is editing it !
;note that this record wasn't copied,
;and come back later to do it !
endif
endif
tcLiveTable.setRange()
endScan
should allow you to update another table safely, even if someone else is editing it. If you know that they'll only be viewing it, you can cut out the part about locking and just copy the new data over the old record.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.