Solved

VB run-time error 91

Posted on 2003-12-02
4
969 Views
Last Modified: 2011-09-20
I sometime have run-time error 91 in my VB application if I click thing too fast. When I click "OK" button it then shut down my application.  Is there a way to ignore the error 91 or trap the error somehow...

I really appreciate any help
thanks,
Majusri
0
Comment
Question by:Majusri
  • 2
  • 2
4 Comments
 
LVL 27

Expert Comment

by:Dabas
ID: 9862013
Hi Majusri,
It always pays to have error handling in all of your procedures.

After your sub or function statment, have a statement that says
On Error goto Error

At the end of the procedure have something like this:

Exit Sub 'So that if everything went OK, the error handling is skipped

Error:
      MsgBox "An Error has occured. " & Err.Description
      'Add code here to ask if the user wants to continue or not
      If the user wants to continue then
            Resume Next 'Program will continue with the statement after the one that caused the error
      Else
            End 'Shut down program
      End IF
End Sub (or Function)

Dabas
0
 

Author Comment

by:Majusri
ID: 9862085
well then I can use on Error Resume Next.... somehow, I only get the error 91 one in a while, not all the time. when there is an error 91 then the application going to shut down. I don't know if it a problem between VB6 and SQL Server 2000 returning the data or if I clicking too fast. All I want to do is to ignore the error 91.


thanks,
Majusri
0
 
LVL 27

Accepted Solution

by:
Dabas earned 30 total points
ID: 9862108
Majusri,
Yes, you can use ON error resume next.
Only then you do not know what errors you are getting and you might get yourself into dangerous waters!
If you are error handling the application should not shut down.

Dabas
0
 

Author Comment

by:Majusri
ID: 9862159
Thank you for your tip. I will now have to implement on Error... on most of my sub.

Thanks Dabas.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

749 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