"Variant does not contain a container"

When opening a form from a view I get this error “Variant does not contain a container”

I have searched the forums, but have been unable to find a post which directly relates to the bug I am getting (despite alot of similar posts)

Below is the code, along with the line where the error appears.

Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)

'Get any need values from parent document

Dim session As New NotesSession

Dim db As NotesDatabase

Set db = session.CurrentDatabase

Dim doc As NotesDocument

Set doc = source.Document

Dim parent As NotesDocument



If Not source.IsNewDoc Then

	Set parent = db.GetDocumentByUNID (doc.ParentDocumentUNID)	

	

	If parent.PRlead(0) <>  ""		Then 

		doc.ProjLead = parent.PRLead(0)

	End If

	

	If parent.CTGDirector(0) <> "" Then

		doc.TechnicalOwner = parent.CTGDirector(0)

	End If

	

	If doc.Assignee(0)  <> "" Then

		AssigneeChanged = doc.Assignee(0) 

	End If

ERRORS OUT HERE —>If doc.CommentsLog(0) <> “” Then

		CommentsChanged = doc.CommentsLog(0) 

	End If

	

End If

End Sub

CommentsLog is blank in this example, and this is an old document. Very odd because the code for Assignee is exactly the same and works fine getting the var value without any erros.

So I am not sure where the problem arises. I did read something about an issue being related to Variant and arrays…this should be a string and not an array and that for some reason the code may be treating it as an array??

Variant seems to be required in the QueryOpen as seen at the top of the code. I am stumped, but will keep searching the forums and post here if I find anything.

Any help is appreciated!

Subject: “Variant does not contain a container”

Sounds like there is no field CommentsLog on your “doc”.

Try adding this to your code:

If doc.HasItem(“CommentsLog”) Then

If doc.CommentsLog(0)  <> "" Then

	CommentsChanged = doc.CommentsLog(0) 

End If

end if

Subject: RE: “Variant does not contain a container”

Interesting that seems to have fixed it. I do not understand why the error would say that the “Variant does not contain a container” when the variable does exist, it just had no value assigned to it.

So the code you wrote actually checks to see if the variable or “container” has a value in it before checking to see if it is an empty string. Is that correct?

Subject: RE: “Variant does not contain a container”

The variant (may) exist but it isn’t set, therefore you cannot access it’s first array element (0) / container.

(I may not be using the terminology correctly)

If you are looking through the debugger you probably see

doc

. . [-] items

. . . . [-] CommentsLog

. . . . . . Value

Notice the Value has no twistie in front of it. If CommentsLog had values you’d see:

doc

. . [-] items

. . . . [-] CommentsLog

. . . . . . [-] Value

. . . . . . . . (0) “Green Eggs and Ham”

Subject: RE: “Variant does not contain a container”

Thanks for helping me and walking through the nuance of the logic.