Returning an exception caught in one procedure to another

right here we go.....

I have a procedure:
Private Sub DataValidation()
        '=============================================================================
        'This procedure is called to ensure all data is valid
        'If not the user is prompted to amend the invalid data
        '3 procedures are called to check the validity of the data held in the 3
        'data input components on screen
        '=============================================================================
        Try
            TitleValidity()
            RateValidity()
            DescValidity()
        Catch
            MsgBox("validation error")
        End Try
    End Sub

NOW... within the first pro(titlevalidity( ) ) that is called I have a if statement where if a criteria is met then I want to display a prompt and stop the processing so say the 'title' hasnt been entered and I want to stop the validation and let the user makes the amendments.
To do this I am using Exit Sub. However this is only exiting the Titlevalidity( ), it then moves on to RateValidity( ).

I want to stop completely.
I'm assuming that I need to have a try..catch in the validity( ) that catches an exception and then parses it back to the try catch in datavalidation( ), is this right and if so how exactly do I do it im a bit unclear.

If not, what do u recommend?

Any1 save a man in need?
scm0smlAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
JohnBPriceConnect With a Mentor Commented:
Yes, like so

   Private Sub TitleValidity()

        Err.Raise(513)
        'or         Throw New System.Exception("An exception has occurred.")
    End Sub
    Private Sub RateValidity()
        MsgBox("In RateValidity")
    End Sub
    Private Sub DescValidity()
        MsgBox("In Desc Validity")
    End Sub
0
 
JohnBPriceCommented:
In TitleValidity you do not need a try catch, you could simply "raise" an error which would be caught at the higher level.
0
 
scm0smlAuthor Commented:
so raising an error in titlevalidity say throw e etc would be automatically passed down?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
JohnBPriceCommented:
In my example, the rate & Desc msgboxes never get shown because the exception gets caught first.
0
 
scm0smlAuthor Commented:
easy when u know how!!

couple of easy points for you, cheers!!
0
 
JohnBPriceCommented:
Thanks....
0
All Courses

From novice to tech pro — start learning today.