?
Solved

Object reference not set to an instance of an object

Posted on 2006-10-23
3
Medium Priority
?
251 Views
Last Modified: 2010-04-16
Getting object refernce errors with the following code. The code breaks at tmpbuild = dbsmain.OpenRecordset("Buildings", DAO.RecordsetTypeEnum.dbOpenDynaset)
  dbsmain is declared in a module. any help appreciated.

Dim tmpbuild As DAO.Recordset

        Dim buildtofindtext As String
        Dim buildid As Integer
        Dim plan As DAO.Recordset
        Dim rsurv As DAO.Recordset
        Dim surveytext As String
        Dim plantext As String
        tmpbuild = dbsmain.OpenRecordset("Buildings", DAO.RecordsetTypeEnum.dbOpenDynaset)
        rsurv = dbsmain.OpenRecordset("Surveys", DAO.RecordsetTypeEnum.dbOpenDynaset)
        plan = dbsmain.OpenRecordset("Plans", DAO.RecordsetTypeEnum.dbOpenDynaset)

0
Comment
Question by:summers_IT
[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 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1000 total points
ID: 17787577
where do you set the object "dbsmain" in your code?
you say "declared", how? and how is is initialized?

Note that anyhow, you need to use SET to assign a recordset object to the variable:

set        tmpbuild = dbsmain.OpenRecordset("Buildings", DAO.RecordsetTypeEnum.dbOpenDynaset)
set        rsurv = dbsmain.OpenRecordset("Surveys", DAO.RecordsetTypeEnum.dbOpenDynaset)
set        plan = dbsmain.OpenRecordset("Plans", DAO.RecordsetTypeEnum.dbOpenDynaset)
0
 

Author Comment

by:summers_IT
ID: 17787646
Thanks,

Your reply has helped me sort this out. I had initialized dbsmain in another window ,both these windows are in a frameset and the window in which in initialized had a parser error.

Thanks for the help, I'm sure I will be back with more questions soon.

Regards,
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 17787686
How is dbsmain declared, and where is it assigned (actaully give a value)?

AW
0

Featured Post

Technology Partners: 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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Starting up a Project
Suggested Courses
Course of the Month8 days, 6 hours left to enroll

766 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