Solved

VB run-time error 91

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

803 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