How to find out the problem? (debug)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I am trying to maintaining a program. However, when I excute it, it show
a error message
Run-time error '91';
Object variable or with block variable not set.
If I select debug, it went to a line of code, which looks ok.
It any tip to find out the problem? Thank you.

the error code is a small Private Sub

Private Sub Form_Open(Cancel As Integer)
Set MeDtls = ndb.OpenRecordset("Record Details", dbOpenDynaset) <---
error happenned
Set SaDtls = ndb.OpenRecordset("Sample Details", dbOpenDynaset)
End Sub

Record Details & Sample Details are tables.
Public ndb As DAO.Database in Globals Declarations
Dim MeDtls As DAO.Recordset in the same form of the Private Sub
fox
 
Wheres the
Set ndb = ... 'something here line

It's easy to test this sort of thing, in thedebug window you would type...

?ndb Is Nothing

.... hit the enter key and most likely get ...
True
 
The debug window is slang for the immediate window, you open it by pressing
Ctrl-G on the keyboard.

It is cused by you not instantiating the object variable that is you haven't
Set variable = ... ' Something here

In this case it's the ndb variable you haven't set.
 
I try ?ndb Is Northing, it said True

Ndb is inside the Globals Declarations Modules
Public Gdb As DAO.Database
How should I do to correct it?

Thank you.

fox
 
As Terry said, you need a line like:

Set ndb = ... 'something here line

That could be

Set ndb = CurrentDB()

or

Set ndb = OpenDatabase("C:\Folder\File.mdb")
 
Ok, I got it. Thank you.

fox

Douglas J Steele said:
As Terry said, you need a line like:

Set ndb = ... 'something here line

That could be

Set ndb = CurrentDB()

or

Set ndb = OpenDatabase("C:\Folder\File.mdb")
 
Back
Top