Hello,
Here is an extract of a program : I don’t understand why I’ve got an Objext variable not set ?
Do you have an idea ?
Thanks a lot for advance…
Gaëtan
Sub main()
Dim sTitulaire As notesitem
Call SignataireSuivant(sTitulaire )
Print sTitulaire.values(0) => Object variable not set
End Sub
Sub SignataireSuivant(sTitulaire As notesitem)
…
…
Set sTitulaire = docSignataire.GetFirstItem( “sSignataire” )
Print sTitulaire.values(0) => 'It prints the correct name => OK
End Sub
Subject: Passing a notesitem by reference
Dim sTitulaire as notesitem
This needs to be in Global Declarations
regards,
raphael
Subject: RE: Passing a notesitem by reference
Hello Raphael
I try your solution, but it does not work.
Subject: RE: Passing a notesitem by reference
Because the NotesItem is dependent on its containing object, NotesDocument. When the temporary NotesDocument object is deleted from memory at the end of the SignataireSuivant routine, it also deletes the NotesItem.
Subject: RE: Passing a notesitem by reference
OK, i understand.
So what is the solution to save the content of my notesitem ?
Can i put it in an array or in an other variables ?
Subject: RE: Passing a notesitem by reference
There are several different things you can do.
If you just want the contents of the NotesItem, you can change the subroutine to return the value rather than the NotesItem.
Sub main()
Dim strTitleArray
strTitleArray = SignataireSuivant( )
Print strTitleArray(0)
End Sub
Function SignataireSuivant( )
…
SignataireSuivant = docSignataire.GetItemValue( “sSignataire” )
End Sub
If you need the NotesItem, you can keep the NotesDocument in memory:
Sub SignataireSuivant(sTitulaire As notesitem)
Static docSignataire As NotesDocument
…
Set sTitulaire = docSignataire.GetFirstItem( “sSignataire” )
End Sub
Or, you could return the NotesDocument instead of the NotesItem, since after all it is easy enough to get a specific item from it. Or you could do whatever you need to do with the item inside the subroutine.
Bear in mind that a NotesDocument is also dependent on its containing NotesDatabase object, so if the NotesDatabase is also a local variable in SignataireSuivant, you will still have the same problem.