Solved

Error 91 Object variable or With block not set

Posted on 1998-12-08
8
248 Views
Last Modified: 2006-11-17
Error 91 Object variable or With block not set.

This is the error I get from the initial form in the "form load" event.

How do I resolve this error? It doesn't appear to be my code. Is there a problem with the compiler? Do I need a new run time? Could the system need new dll's?

Any assistance greatly appreciated.

Melvin
0
Comment
Question by:Melvin
8 Comments
 
LVL 7

Expert Comment

by:tward
ID: 1448765
Showing the code from the Form_Load event will help.
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1448766
Does it happen only at run-time? Otherwise you can see the line that failed.
The reason is that one of your objects is nothing
0
 
LVL 3

Expert Comment

by:kfrick
ID: 1448767
I have found that the Form_Load event is not the place to initialize features of your form, because thay do not yet exist! The form has not yet created the control you are trying to modify with your code.

I have used two methods. The first is th Form_Activate event:

Sub Form_Activate()
Static bInit as boolean
  If Not bInit then
    ' put your initialization code here
    bInit = True
  End If
End Sub

The bInit boolean prevents your code from running more than once. It will run the first time the form is opened.

The other soliution is to put a timer on your form, and use the Timer event to initialize your form:

Put a timer on your form. Call it tmrStartUp. Set it's Enabled property to True. Set it's Interval property to 100. Paste this code to the form:

Sub tmrStartUp_Timer()
  tmrStartUp.Enabled = False
  ' putyour initialization code here
End Sub

Play around with these two schemes to find which one you like best!

Good Luck!

-kf
0
 

Author Comment

by:Melvin
ID: 1448768
I have additional information.  The object is a database created using Visual Basic.  I have upgraded Visual Basic with Service Pack 2.  Now I can't open the database.  The more descriptive error message is: 3041 --  Can't open a database created with a previous version of your application.

I suppose I will have to reinstall the original VB and not include Service Pack 2.  This may resolve the problem.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Expert Comment

by:dgb001
ID: 1448769
I wondered if it might be database related, I'm sure the comments above are more helpful than this, but I got the same error 91 recently, which was the result of trying to close a database table before it was opened.


0
 

Author Comment

by:Melvin
ID: 1448770
I resolved the problem by upgrading the database. The problem was that I built the database using VB. When I installed Service Pack 2 in VB, my application could no longer open the database created with the older version of VB. Using Microsoft Access I converted the database to Access 7.0 and now everything works fine.

I appreciate kfrick's response, but my failure to adequately explain the issue initially, resulted in an answer that didn't resolve my problem. My fault.
0
 
LVL 3

Expert Comment

by:kfrick
ID: 1448771
No problem! Glad you found the answer! Happy Holidays!
-kf
0
 
LVL 7

Accepted Solution

by:
linda101698 earned 100 total points
ID: 1448772
I am posting the solution found by Melvin so it can be saved in the previously asked questions.  Please see your customer service question for an explanation.

Linda Gardner
Customer Service @ Experts Exchange


Comment
     From: Melvin
                                  Date: Monday, December 21 1998 - 06:01AM PST

     I resolved the problem by upgrading the database. The problem was that I
     built the database using VB. When I installed Service Pack 2 in VB, my
     application could no longer open the database created with the older version
     of VB. Using Microsoft Access I converted the database to Access 7.0 and
     now everything works fine.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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 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…

708 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

14 Experts available now in Live!

Get 1:1 Help Now