Hi, I am new to lotus and currently facing a problem dealing with the code shown as below:
Dim session As NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Set session = New NotesSession
Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument
Dim award As Variant
award = doc.GetItemValue( “AwardHistory” )
Messagebox( award( 0 ) )
This code is copied exactly same from the example in the ‘help’ session, but not the field name only. However, I got an error message with “Object Variable Not Set” with this code. I still couldn’t find out which line of the code brings out the error. Can anyone enlighten me about this ? Thank you in advanced!
This code will run through each NotesDocument in your NotesDocumentCollection. If there IS no initial NotesDocument, it will not run.
Since GetItemValue returns an array of values from the target NotesItem (in this case “AwardHistory”), we’re going to use a Join to combine all values into a single String. I’m assuming of course that AwardHistory only has a single value. If there is no value in this NotesItem or the “AwardHistory” NotesItem doesn’t exist, it will return “”.
Subject: Debugger gives information; YOU must solve the problem.
I see your problem.
Some methods and properties in LotusScript are sensitive to the context in which they’re used. You can’t simply take any sample code and paste it in anywhere you like, and assume it will work. Think about the meaning of what you’re doing in the given context.
Read the documentation for the functions you are using, particularly UnprocessedDocuments.
Read Debugging Domino Applications part 1 and part 2 .
In the debugger, pay attention not only to which line generates the error, but also to what happens on previous lines, and the values of variables. Often the mistake that causes an error is an incorrectly assigned variable, but the error message doesn’t occur until you try to use that variable later.
Pay special attention to the Usage section of the method/property descriptions.