Object Variable not Set Error

I dont know what is happens

Dim key As String

Dim item As notesitem

If Not (key=“”) Then

Call item.AppendToTextList(key)//ERROR HERE

Else

Set docNew = viewNew.GetDocumentByKey(Cstr(fieldvalue),True)

Dim code As Variant

code= docNew.GetItemValue( "Code" )

Call item.AppendToTextList(code)'//ERROR HERE

end if

What I did wrong here?

Thanks for help,

Subject: Object Variable not Set Error

where did you set item??

as in

set item = doc.getFirstItem( “your field”)

John

Subject: RE: Object Variable not Set Error

yes…

Set item = doc.GetFirstItem( “test” )

Subject: RE: Object Variable not Set Error

This error means that there is no “test” field in your document, hence the object is not set, and the property cannot be called.

You should always test your objects before using their properties.

if item is nothing then

messagebox “No test field. Aborting…”

else

’ do your stuff here

end if

Subject: RE: Object Variable not Set Error

I don’t see it in your original code. Could it be that the field is not defined in your form, therefore it has not value ie.

set item = doc.getFirstItem( “your field”)

if item is nothing then

call doc.replaceItemValue( “your field”, “”)

set item = doc.getFirstItem( “your field”)

end if

else post the code where we can see where you set it.

John