Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do you handle update collision?
Message
From
06/07/1999 21:24:05
 
General information
Forum:
Visual Basic
Category:
Database DAO/RDO/ODBC/ADO
Miscellaneous
Thread ID:
00238025
Message ID:
00238063
Views:
16
Thank you very much for your reply Éric.

I've set up my On Error routine, except that Err.Number = 0 when saving a record modified by another user.

Here's the scenario:
- Start the EXE (A)
- Start a second copy pf the EXE (B)
- In A, edit the record but don't save (the command Edit is called when the record is displayed)
- In B, go to the same record, do some changes and save it (everything work fine so far)
- In A, press the Save button (Update is called)

The On Error routine is called, but Err.Number = 0. Why?

Here is the code:
    On Error GoTo UpdateError
    rsContrats.Update
    On Error GoTo 0
UpdateResume:
    SetMode "C"
    RefreshFields
    Exit Sub

UpdateError:
    On Error GoTo 0
    
    Select Case Err.Number
    Case 3167   ' Record is deleted
        MsgBox "Le contrat a été effacé par un autre usager"
        Resume UpdateResume
    Case 3186, 3197   ' 3186 - Couldn't save, currently lock
                      ' 3197 - Data has changed
        MsgBox "Un autre usager a modifié ce contrat. Les modifications n'ont pas été sauvées"
        Move 0
        Resume UpdateResume
    Case Else

==> This is what is called and "Erreur # 0" is displayed

        MsgBox "Erreur # " & Str(Err.Number) & " " & Err.Description
        End
    End Select
BTW, I'm using Access 97.

TIA

>You are right. You have to handle error using the "On Error Goto Somewhere" statement.
>
>The most important errors you should check for are the following:
>3260: Couldn't update, currently lock (can occur on Edit). Should not be a concern on Optimistic locking.
>3186: Couldn't save, currently lock (can occur on Update).
>3197: Data has changed, operation stopped (can occur on Edit and Update).
>3167: Record is deleted (can occur on Edit and Update).
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform