PRB: Valid Routine Results in "Record Not Locked" Error

ID: Q111919

The information in this article applies to:

SYMPTOMS

A VALID clause on a GET field or BROWSE field accidentally releases an automatic record lock, causing a "Record Not Locked" error message when the valid routine returns .F. The error will not occur if the valid routine returns .T.

CAUSE

The following sequence of events will cause the automatic record lock to be released:

1. The record lock is placed automatically through a command, such as READ

   or BROWSE.

2. During the VALID routine, the record pointer is moved to a new record.

3. Another command, such as REPLACE, that places an automatic record lock

   is executed on the new record position. Since only one automatic record
   lock can be effective at a time, the original lock is released when the
   new lock is placed.

4. The VALID routine returns a .F. value. Control returns to the original
   GET field or BROWSE field, causing the record pointer to be moved back
   to the original record. The automatic record lock has been released,
   which causes the error to occur when editing control is returned to the
   field.

RESOLUTION

There are two possible resolutions:

MORE INFORMATION

Steps to Reproduce Problem

1. Create a TEST database by issuing the following commands in the

   Command window:

      USE tutorial/customer
      COPY TO test NEXT 10
      USE test
      INDEX ON cno TAG cno
      SET ORDER TO TAG cno

2. Create a program file named LOSELOCK with the following commands:

      m.cno = cno
      m.recno = RECNO()
      SEEK m.cno
      IF FOUND()
         WAIT WINDOW "Record exists"
         REPLACE cno WITH m.cno
         RETURN .F.
      ENDIF

3. In the Command window, issue the following command:

      BROWSE FIELDS cno :V=loselock(), company, contact

4. Use the DOWN ARROW key to move to the third record.

5. In the CNO field, type the same customer number that appears in the

   first record. A "record not locked" error should occur.

Additional reference words: FoxMac FoxDos FoxWin 2.50 2.50a 2.50b errmsg err msg KBCategory: kbprg kberrmsg kbprb KBSubcategory: FxprgBrowse

Last Reviewed: June 27, 1995