db.IsOpen returning error

Hi, I have an agent that is supposed to open a database on a server, test to make sure that the DB was actually opened, and then perform some actions. Here is my code:

Dim s As New NotesSession

Dim db1 As NotesDatabase

Set db1 = s.GetDatabase(“gfrdoc01.sby.ibm.com”, “c_dir\cfes.nsf”, False)

If db1.IsOpen = True Then

    ...

    ...

   Else

   MsgBox "Cannot Connect"

   End If

But that code returns an “Object Variable Not Set” error at the If db1.IsOpen line when the DB is unreachable, rather than my error message. Any idea what I’m doing wrong?

Thanks!

Subject: db.IsOpen returning error

I believe, you need an On Error…GoTo statement.

Subject: db.IsOpen returning error

I think using GetDatabase returns nothing, so check ‘if not db1 is nothing’

If you use the New Database method you can then check whether db1.isopen (look at the examples in the designer help)

Dan

Subject: RE: db.IsOpen returning error

Dan, that was it. Thanks!