Solved

VB run-time error 91

Posted on 2003-12-02
4
965 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now