Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Record is in use by another user (Error 109)
Message
From
14/06/2002 07:58:55
 
 
To
14/06/2002 00:50:28
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00667772
Message ID:
00668450
Views:
21
Hi Robin.

So the use a makeshift solution, just set the AllowAddNew property to false. And while user in the the last column of last row(maybe not last row) in the grid, he or she could press a hot key to insert a new row. Like press CTRL_ENTER or CTRL_INSERT key to inform the program.

I do not think that this is a makeshift solution. It is the one that I use because it gives me more program control over how records get added to the grid. Code like this is the grid text box's KeyPress will add a new record when F5 is pressed:
*** Check to see if F5 was pressed
IF nKeyCode = -4
  WITH This.Parent.Parent
  *** Set Focus elsewhere to avoid Record in use by another error
  *** when we set focus to the first column of the newly appended record
  *** Also, if we do NOT set focus elsewhere, even though the AddNewRecord() method
  *** Does indeed add a new record, the newly appended record appears as the first
  *** line in the grid and the cursor moves to column 1 in the last row of the grid 
    .lAdding = .T.
    .Parent.SetFocus()
    .AddNewRecord()
    .lAdding = .F.
    NODEFAULT
  ENDWITH	
ENDIF	
Code like this in the grid's AddNewRecord method:
LOCAL lcOrder, loColumn
WITH This
  *** First check to see if we have an index order set on the table
  *** because we want add the new record to the bottom of the grid
  *** and not in index order
  lcOrder = ORDER( .RecordSource )
  Thisform.LockScreen = .T.
  SELECT ( .RecordSource )
  SET ORDER TO 
  APPEND BLANK IN ( .RecordSource )
  *** Find out which column is the first column
  FOR EACH loColumn IN .Columns
    IF loColumn.ColumnOrder = 1
      loColumn.SetFocus()
      EXIT
    ENDIF
  ENDFOR
  *** Reset the previous order		
  IF ! EMPTY( lcOrder )
    SET ORDER TO ( lcOrder ) IN ( .RecordSource )
  ENDIF
  .RefreshControls()
  ThisForm.LockScreen = .F.	
ENDWITH	
I have no enough konledge to check out the bug is surely about the allowAddNew property of grid object or not. Maybe here someone else could make it out. I hope my solution also helpful to you. Also I will thanks all the persons here have given the help to me.

This bug is not about the AllowAddNew property. it occurs whenver you try to modify a record in the Grid's RecordSource programmatically while the grid has focus.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform