error handling

  • Thread starter Thread starter SAC
  • Start date Start date
S

SAC

Access 2000

I'm trying to make an error 3021 - "No current record" skip over some code,
reset the error object and move on.

I've tried

Const conTypeMismatch As Integer = 3021
If Err.Number = conTypeMismatch Then
Err.Clear
GoTo Exit_MayCauseAnError
End If

But this is testing BEFORE the error occurs.

How can I fix this?

I don't think there's an ON ERROR 3021 goto...or is there?

That would be great.


Thanks.
 
What you need to do is define an Error Handling routine to which the code
will be directed. I don't have a copy on this machine but in your function

Function XYZ()

ON ERROR GOTO ErrorHandler:

Dim ........

rest of your code

Exit Sub

ErrorHandler:

code to select which error has arisen and action (or step around it)

Resume Next ' Continues code from the next line below the
error

End Sub

note the Exit Sub / ErrorHandler:. If your code works correctly it makes it
out before the ErrorHandler. If there's and error then surprisingly it
jumps in.
 
Back
Top