Solved

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

Posted on 2001-09-18
3
290 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
ID: 6490803
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
ID: 6490950
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
ID: 6492080
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…

911 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

17 Experts available now in Live!

Get 1:1 Help Now