I have a pushbutton with the following code. I am trying to archive a record from a customer database but when I delete the record I need to give a reason for the deletion and the date of the deletion. The code copies across the record into a table with the same structure with the added information but then stops with the error message "unable to find lookup value" and then goes no further, thus not deleting the record from the orginal table. Any help would be most apreciated. Many thanks,
Lewy
var
tcOrig, tcArc Tcursor
F Form
remove String
arcRec Array[] anytype
endvar
edit()
tcOrig.attach(Clients) ; sync TCursor to CUSTOMER pointer
switchmenu
case "Deceased" :tcOrig.Reason="Deceased"
case "Gone Elsewhere" :tcOrig.Reason="Gone Elsewhere"
case "Moved Away" :tcOrig.Reason="Moved Away"
Case "Under Hopsital" :tcOrig.Reason="Under Hospital"
endswitchmenu
if msgQuestion("Confirm", "Delete record?") = "Yes" then
disableDefault
tcOrig.copytoarray(arcRec)
edit()
tcOrig.DateRemoved=today()
view(arcRec)
if tcArc.open("Cust1Archive.db") then
tcArc.edit()
tcArc.insertrecord()
tcArc.copyfromarray(arcRec)
enableDefault ; process DataDeleteRecord now
else
msgStop("Stop!", "Sorry, Can’t archive record.")
endIf
else ; else user didn’t confirm delete
message("Record not deleted.")
endIf
; else form is not in Edit mode
msgStop("Stop!", "Press F9 to edit data.")
Lewy
var
tcOrig, tcArc Tcursor
F Form
remove String
arcRec Array[] anytype
endvar
edit()
tcOrig.attach(Clients) ; sync TCursor to CUSTOMER pointer
switchmenu
case "Deceased" :tcOrig.Reason="Deceased"
case "Gone Elsewhere" :tcOrig.Reason="Gone Elsewhere"
case "Moved Away" :tcOrig.Reason="Moved Away"
Case "Under Hopsital" :tcOrig.Reason="Under Hospital"
endswitchmenu
if msgQuestion("Confirm", "Delete record?") = "Yes" then
disableDefault
tcOrig.copytoarray(arcRec)
edit()
tcOrig.DateRemoved=today()
view(arcRec)
if tcArc.open("Cust1Archive.db") then
tcArc.edit()
tcArc.insertrecord()
tcArc.copyfromarray(arcRec)
enableDefault ; process DataDeleteRecord now
else
msgStop("Stop!", "Sorry, Can’t archive record.")
endIf
else ; else user didn’t confirm delete
message("Record not deleted.")
endIf
; else form is not in Edit mode
msgStop("Stop!", "Press F9 to edit data.")