Application Level Error Handling - its very urgent

Posted on 2005-03-25
Medium Priority
Last Modified: 2010-05-02
i need to update some database values when my VB application raises run time error at any part of the application
does VB allow Application level error handling if yes then how can i do this.
Question by:imrancs
LVL 53

Expert Comment

ID: 13629601
Do you have any error-logging ?
LVL 32

Assisted Solution

Erick37 earned 400 total points
ID: 13629890
LVL 38

Accepted Solution

PaulHews earned 1200 total points
ID: 13630005
You have to have error handling in every sub, and in that error handling, call a central routine.  (Yeah, that sucks I know.  Don't shoot the messenger please. :)  There are products out there that can help you do this.


These are a couple from a seach on vb error handling automation.

The freeware MZTools addon allows you to add error handling to *new* subs and functions but doesn't do a retrofit.
LVL 38

Assisted Solution

PaulHews earned 1200 total points
ID: 13630022
VB.NET has structured error handling and allows you to catch an exception at the application level if needed.  So if you haven't started your project yet, and you aren't that familiar with vb, .NET etc, you might want to review your options.
LVL 33

Assisted Solution

by:Robberbaron (robr)
Robberbaron (robr) earned 400 total points
ID: 13642007
VB does have some cascading of errors that should help....

try this
Option Explicit

Private Sub Command1_Click()
    On Error GoTo cmderr
    Exit Sub
    MsgBox "CmdErr:" & Err.Number, vbCritical + vbOKOnly
End Sub

Sub test1()

Err.Raise 27

End Sub

Private Sub Form_Load()

End Sub

You will see that although the error was raised in the routine Test1(), the error was trapped back at Command1_click as there was no local error handler.

I think that if you have a local error trap, but dont want to handle the particular error there, you can call the err.raise method within the local error routine, forcing the error to cascade back to the previous routine in the call stack.


Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question