Problems opening db w/ agent

Hello,

When running my code I get the following error (database \dbname has not been open yet).

here is a piece of my code;

Dim db As New NotesDatabase “” , “mailbox.nsf”)

Dim view As NotesView

Set view = db.GetView (“Date Collection”)

Dim doc As NotesDocument

Set doc = view.GetFirstDocument

'Dim temp variables

Dim vMth As Variant

Dim vYr As Variant

Dim vMthYr As Variant

Dim sMth As String

Do Until doc Is Nothing

vMth = Left(doc.GetItemValue(“DateComp”)(0),3)

vYr = Right(doc.GetItemValue(“DateComp”)(0),4)

vMthYr = vMth & vYr

sMth = Month(Today)

If sMth = “1” Then

If vMthYr = “Dec” & Year(Today) Then

Call doc.PutInFolder(“Dec” + Year(Today))

End If

End If

If sMth = “2” Then

If vMthYr = “Jan” & Year(Today) Then

Call doc.PutInFolder(“Jan” + Year(Today))

End If

End If

Set doc = view.GetNextDocument(doc)

Loop

Subject: problems opening db w/ agent.

After your first line, add the following:

call db.Open(“ServerName”,“DBName”)

This should do the trick I think. Before you can access certain properties and methods of a DB in LotusScript the DB needs to be opened, otherwise you get the error you referred to.

Hope this helps…

Subject: problems opening db w/ agent.

The most common reason for this error message is a security violation. So check the ACL for the effective user of the agent. To understand the security issues in agents, you might find Agnet FAQ articles about agents helpful. It also gives you example of some error handling code, and some tips on troubleshooting various common agent issues.