VB CODE

R

rblivewire

I have this code that I use to trap a multinumber error and replace it
with one greater than the highest one:

Private Sub saveCloseButton_Click()
'On Error GoTo Err_saveCloseButton_Click
On Error GoTo Err_Form_Error


Response = IncrementField(DataErr)


If MsgBox("Are you sure you want to save and close this request?",
vbQuestion + vbYesNo) = vbYes Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
DoCmd.Close


End If


'Exit_saveCloseButton_Click:
'Exit Sub


Exit_Form_Error:
Exit Sub


'Err_saveCloseButton_Click:
'MsgBox Err.Description
'Resume Exit_saveCloseButton_Click
' End If
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


When it gets to the function though it skips over:
Me![#] = (DMax("[#]", "Tool Tracking List") + 1)
IncrementField = acDataErrContinue


This is the main code I need it to run. Any reason why it skips over
this??
 
K

Klatuu

At the point you are checking for the error, no error has occured. I don't
know where you got that code, but in it's present form, it will not work at
all. One other thing. naming a field [#] is about as bad as naming can get.
First, it is not a valid character for use in name (That is why it will
always have to be bracketed), and second, it is totally meaningless.
 

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