• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 253
  • Last Modified:

Object reference not set to an instance of an object

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
summers_IT
Asked:
summers_IT
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
 
summers_ITAuthor Commented:
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
 
Arthur_WoodCommented:
How is dbsmain declared, and where is it assigned (actaully give a value)?

AW
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now