On error display

R

rblivewire

I have a form that has a code that automatically generates the next
number from the highest number: (Default Value =DMax(" [#] ","Tool
Tracking List")+1) With this I want to customize it for a multi-user
environment. I tried this code to get automatically generate the next
number up on an error, but its not working. It just gives the duplicate
value error and an OK button, but doesn't change the number to the next
one up. Anything wrong with the 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!ProductID = DMax("ProductID", "Product") + 1
IncrementField = acDataErrContinue
End If
End Function
 

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

Top