Error Handler in a Function Routine

Guirg

Registered User.
Local time
Today, 12:19
Joined
Jun 2, 2009
Messages
96
Hey All

Sick of hitting my head against a wall on this one... i put in the

Code:
Buildfilter = varWhere
On Error GoTo Panicstations
Panicstations:
    MsgBox "Invalid Input - Clearing Form"
    btnClear_Click
    Err.Clear
End Function

and i cant get it to run through without constantly repeating the last few lines.. as its sitting in the Buildfilter function and thats the search function :(

cheers
 
or at least how do i limit an if statement to If me.txtdatemin = 10 charaters then continue?
 
not sure exactly what you are doing but, see the red bits

1. you have to ensure you don't enter the error handler inadvertently
2. you have to issue a resume statement IN the error handler - otherwise you are STILL running in the error handler (whatever your code does), and you can't activate another (or the same) error handler.

Code:
Buildfilter = varWhere
On Error GoTo Panicstations


[COLOR="Red"]'point 1
'so you don't fall into the error handler

other code

mylabel:
exit sub[/COLOR]


Panicstations:
    MsgBox "Invalid Input - Clearing Form"
    btnClear_Click
    Err.Clear

    [COLOR="red"]
'point 2 - resume statement
     resume mylabel[/COLOR]
End Function
 
ahahahah you sir are a legend! i had to move it to where the filter is being exectued and instead of where i was trying to implement it but it works! massive load off... now to the next bug :P
 

Users who are viewing this thread

Back
Top Bottom