AndrewMozley
Programmer
A transaction (entering details of a warranty claim) results in appending records to some tables and updating a record in a third table (Customers). This last action may meet a problem if the relevant record is already locked.
In this last case the system wants to offer the user the chance to release the lock - maybe by closing some other open form – and trying again.
At present there is (in effect) this code :
Wait4Me() is a function kindly provided by csanduu on this site many years ago. It waits a few seconds and lets the user click on another form if he needs to; and for the RLOCK to work effectively SET(“REPROCESS”) <> 0
As far as I can see this code achieves the result. But if there is a better way of doing it I would be grateful for guidance.
Thanks. Andrew
In this last case the system wants to offer the user the chance to release the lock - maybe by closing some other open form – and trying again.
At present there is (in effect) this code :
Code:
BEGIN TRANSACTION
SELECT <table1>
APPEND BLANK
REPLACE <field1> WITH <value1>, <field2> WITH value2> . . . .
SELECT <table2>
APPEND . . .
REPLACE . . . .
. . .
SELECT <Customer>
LOCATE <required record>
DO WHILE .T.
IF RLOCK()
REPLACE <fieldname> WITH <Customer>.<Fieldname> + 1
UNLOCK
END TRANSACTION
ELSE
lAnswer = MESSAGEBOX(“Customer record locked. Do you want to try again?”,4)
IF lAnswer <> 6
ROLLBACK
MESSAGEBOX (“Transcation abandoned”)
EXIT
ENDIF
ENDIF
Wait4Me(5)
ENDDO
Wait4Me() is a function kindly provided by csanduu on this site many years ago. It waits a few seconds and lets the user click on another form if he needs to; and for the RLOCK to work effectively SET(“REPROCESS”) <> 0
As far as I can see this code achieves the result. But if there is a better way of doing it I would be grateful for guidance.
Thanks. Andrew