Autonumber in multiuser environment

  • Thread starter Thread starter rblivewire
  • Start date Start date
R

rblivewire

I have a formula that adds 1 to the hightest number and this is my
autonumber. I am trying to get it to work in a multiuser environment
by using this code:

Private Sub Form_Error(DataErr As Integer, Response As Integer)
On Error GoTo Err_Form_Error

Response = IncrementField(DataErr)

Exit_Form_Error:
Exit Sub

Err_Form_Error:
MsgBox Err.Description
Resume Exit_Form_Error

End Sub

Function IncrementField(DataErr)
If DataErr = 3022 Then
Me![#] = DMax("[#]", "Tool Tracking List") + 1
IncrementField = acDataErrContinue
End If

End Function

It is supposed to trap the error and then add 1 to the number. The
code doesnt seem to trap the error. It simply gives me the error and
an ok button. Can anyone see why its not trapping the error???
 
It never makes it to your Response = statement because the On Error GoTo
statement grabs it first. You're double-trapping the error. The Form_Error
event only fires when there's an error, so it will always go to the error
handler.

I would suggest removing the error handler in the Form_Error event. If you
want error handling in the IncrementField function, put it there.

Barry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top