9 Warning: Record already locked in this session.

Problem: Getting warning "Warning: Record already locked in this session."

1: When running a form and editing records.
Versions: P5 - P8
More information:
see fixed bugs PX0263


Versions: P7 and later
More information:
see current bugs PX0274


Versions: P8-P10
More information:
see fixed bugs PX0522


Versions: All
Possible cause by : Adrian Fowle
The Paradox data model locks the master when you edit the detail record. Therefore if you try to edit detail records in several forms at once, you get this error. The solution seems to be to invert the data models so that they are M:1 eg child -> parent, and use filters on the parent key within the child record.

I think maybe Paradox is putting a write-type lock on the master when it could perhaps make do with a read lock? There is another consequence of this. I had wanted to explicitly lock the parent record to indicate that the current user had access to this parent (on a network). But 1) Cant then edit as above & 2) It looks as if record locks can sometimes be overridden by other users so that you have to cancel your changes and start again (according to the manuals).


2: When editing data in a table frame with code in mouseEnter event in a field in the table frame.
Date: 19 September 2002
Versions: P10
Description:
On my form there is a tableframe and I want the user to enter data (the color) into the field project via mouse!
method mouseEnter(var eventInfo MouseEvent)
if isEdit() then
    if eventInfo.isShiftKeyDown() then
       self.value = liCol
    endif
endIf
endMethod
It works fine with the first entry, but the second is stopped by an error (the record is already locked in this session).

Explanation by: Bertil Isberg < bertil.isbergATscb.se >
MouseEnter does not change the active object, so you get a conflict between self and the active object in the table frame
In MouseEnter, you need a line
self.moveto()
before you assign a value to the field


3: When *reading* a field value in a form.
Date: 24 May 2003
Versions: All
Other symptoms:
Error "An error occurred when trying to get the property named 'Value' of the object named '<>' of type 'Field'." is on the error stack.

Explanation by: "Vladimir Menkin" < vmenkin.homeATITS-surveys.com >
Under some conditions *reading* a field value in forms causes "Record alredy locked" message. Not sure, though, that the exact conditions which produces this message has been determined. So, just in case, I describe here one of such conditions.

This message always arises when the form has a locked record, and the program tries to *read* a field value using UIobject variable, attached to any other (not those which is locked) record. In this case the original error shown is: An error occured when trying to get property named value of the object named N of type field.

Example code to make the setup easier to understand:
A is a tableFrame. Code locks first record, and then tries to get the value from another record using runtime binding to record object without first unlocking the current record. Original recordobject has name #Record7.
var
 u uiobject
 i smallint
endvar


; N is a field in tableframe named A
N.home()
N.moveto()
edit()
N.LockRecord()
u.attach("#Page2.A.#Record25.N") ;this is the noisy name of the last record in TF
try
   i=u.value
   i.view()
onfail
   errorpop()
   errorshow()
endtry

To index