Solved

Object reference not set to an instance of an object

Posted on 2006-10-23
3
247 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
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using YubiKey with REST API application 2 116
move one pixel 4 67
Hide vba in gp 7 94
Using VBscript & RegEx, how can I match lines starting with Oracle word 17 59
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

770 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