NotesItem - Object Variable not set

Hi All,I have changed a text field into rich text. To add attachments to the field what I did is, Created a Notes Item for the field, got its contents stored in a variant, removed the item, created a new rich text item and added the contents from the variant and added the attachment. Things went fine for most of the documents. But for some documents I got a Object variable not set error

Dim item As NotesItem

Set item = Doc.GetFirstItem(“xxxxxxxx”)

If item.type<>1 then

'code to store in variant and remove item

end if

In the line item.type i get Object variable not set error. When I used debugger, I found that Item was not set. But in the document there is a field with some value. Also in such documents, When i check the fields datatype in the document properties, it shows “textlist”.

Please advice me on how to process such documents.

Thanks in Advance.

Subject: NotesItem - Object Variable not set

Hi,

their is a difference between a field that you create with the designerclient and a field you create with Lotus Script.

If you create a new document with Lotus Script you have to declare the items of this document as follows :

Dim item as New Notesitem(doc,itemname,value) or

doc.itemname = value

You have to do this even if the form you use has the items .

Greetings

Raul

Subject: RE: NotesItem - Object Variable not set

Hi Raul, Thanks for your response. Let me be more clear with the problem.

Actually my problem is not with creation of field. I run my agent over the existing documents and check for the field type. If field type is not rich text then make them as richtext (set rtitem = new notesrichtextitem(doc,"body)). The problem occurs when I try to find the field type.

I get the error at item.type (item is not set). When I check the document property, the field type is “Text list” .

It doesn’t occur with all the document, only in the document where the field type is text list.

Subject: RE: NotesItem - Object Variable not set

If there really is such an item in the document, then the item variable would not be Nothing. There is in fact no such item. If you see it in the document properties, then you are either looking at the wrong document, or looking at the properties in the wrong context (e.g. while the document window is open). Look at the document properties from a view.

Incidentally, if you declare something as type NotesItem and then try to assign it a rich text item object, this assignment will fail because the variable is of the wrong type. You will have to declare item as variant instead (or else trap the error and do your rich-text action in the error trap).

Subject: RE: NotesItem - Object Variable not set

Hi Andre, Thanks for your response.You are correct. I checked the document properties when the document is open. When I checked from the view, there is no such item.