Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Optimistic Locking - Bound Form - Access 2000

Status
Not open for further replies.

KenReay

Programmer
Aug 15, 2002
5,424
0
0
GB
Hi

I am using Optimistic Locking (.RecordLocks = None), with a bound form. Does anyone know if it is possible to trap the standard Access message given when two users change same record (ie the message giving three choices Save and overwrite other users changes, discard changes, save to clipboard), my present user base find this too complex, so I would like to replace is with a custom message giving fewer choices



Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
From what I remember that is an Data Error (can only be trapped through the On Error Event), so you should be able to trap it through the On Error Event.

You will need to watch for the DataErr No, if you dont know the number just add an msgbox DataErr.

You will need to add an response = acDataErrContinue (no display of standard message) or repsonse = acDataErrDisplay

Hope this helps


Gavin,
 
Hi

Could you give an example

I have an OnError GoTo statement in, but no error is being trapped

I have the code in the onclick event of a Save command button

Procedure CmdSave_Click
On Error GoTo Error_Click
DoCmd.RunCommand acCmdSaveRecord
Exit_Click:
exit sub
Error_click:
' never get here
End Sub

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hi

Thanks for the link Hymn, more knowledge never hurts!

That example was for updating via recordset, so I will store it away for future use. In the meantime I think I have what I am looking for, just testing it out now, what I have done is briefly as follows:

Put code in the Form_Error event, trap the errors (DateErr), 7787, 7878, 3262. These are Jet Errors not Access errors
Used the Response parameter to change the standard behaviour, using acDataErrContinue and acDataErrDisplay constants to display my owm message and handle the situation

As I say, I am testing the result now, looks promising

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hi!

Think this is dataerr 7787, but do a msgbox DataErr within the forms on error event to be sure, then it might look like this:

[tt]private sub form_error(dataerr as integer, response as integer)
if dataerr=7787 then
response=acdataerrcontinue
' disable the default msgbox
end if
end sub[/tt]

- but this will throw an exeption at the save command too, perhaps the 3197? Then also trap for that, perhaps something like this:

[tt]Procedure CmdSave_Click
On Error GoTo Error_Click
DoCmd.RunCommand acCmdSaveRecord
Exit_Click:
exit sub
Error_click:
if err.number=3197 then
msgbox "you and another... not saved..."
else
msgbox err.description
end if
resume Exit_Click
' should get here
End Sub[/tt]

Think the challege is that the dataerr is evaluated before the saveroutine has a chance to throw an exeption, but trapping for it like this might do.

Another thing, sometimes those savecommands doesn't throw an exeption, see osing data when you close a form - sometimes using his method is quaranteed to throw an exeption should there be errors in the save process

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top