Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Record is in use by another user (Error 109)
Message
 
 
À
14/06/2002 07:58:55
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00667772
Message ID:
00668491
Vues:
29
>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.

Marcia,

I believe your last statement needs a little bit of clarification. It should be reffered to this new added record, I believe. There are two articles in MSDN about similar bugs, but they both talk about insertion.

I was struggling with this bug for quite long time. Once I changed Buffering mode of the table, which was used just for Lookup purposes in the grid, to 5, the problem went away.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform