Solved

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

Posted on 2001-09-18
3
295 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
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…
Suggested Courses
Course of the Month11 days, 14 hours left to enroll

623 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