Solved

"91 Object Variable or Block Width Variable Not Set" Error

Posted on 2001-09-18
3
289 Views
Last Modified: 2011-10-03
I have a DLL that is being loaded and throws this error at runtime: "91 Object Variable or Block Width Variable Not Set".  What does it mean?  How can I solve it?  It sounds like a NullPointerException.  
0
Comment
Question by:hotwheels
3 Comments
 
LVL 1

Accepted Solution

by:
ripnasty earned 100 total points
Comment Utility
That error usually means that you make reference to an object somewhere in your startup code that hasn't been set to anything.

For example, if you declare a recordset (rsTest) but don't set it to anything and make reference to it, you will get this error

i.e.

Dim rsTest as Recordset
If rsTest.EOF then
.
.
.
End If

The rsTest.EOF will produce an Object Variable Not Set error because it hasn't been set to anything.  Trap through your startup code and debug will tell you whether your object variables have been set or not.

Hope this helps!
0
 
LVL 22

Expert Comment

by:rspahitz
Comment Utility
ripnasty is correct and forgot to show the usual cure:

Dim rsTest as Recordset

' add this line
set rsTest = new Recordset

If rsTest.EOF then


--
In the case of a class, do the same thing:

Dim clsMyOwnClass as ClassName

Set clsMyOwnClass = New ClassName

clsMyOwnClass.MyProperty = MyValue

...
0
 
LVL 4

Expert Comment

by:VincentLawlor
Comment Utility
Yes as the others have said this is due to declaring an instance of an object and not instanciating it.

Examples:

'Object declaration
Dim objMyObject as MyObject

objMyObject.MyProperty = 1
or
objMyObject.DoSomething

This will give this error.
The correct syntax is.

Dim objMyobject as MyObject
Set objMyObject = new MyObject
or
Dim objMyobject
Set objMyObject = CreateObject("MyObject")
or
Dim objMyobject
Set objMyObject = GetObject(,"MyObject")

The following will also cause this error.


Dim objMyObject as MyObject 'Declaration
Set objMyObject = new MyObject 'Instance

myObject.MyProperty = 1
myObject.DoSomething

Set MyObject = Nothing 'Object destroyed

myObject.MyProperty = 1

This will also give the error.

So have a good look at the code an make sure objects are being created properly and not being used after they have been destroyed.  

This is the same as the NullPointerException in Java.

Vin.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

763 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

12 Experts available now in Live!

Get 1:1 Help Now