Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2001-09-18
3
Medium Priority
?
297 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 400 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…
Suggested Courses

688 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