I have a Function call GetUserDoc that goes out a gets a document from the NAB. When I call this function inside my main program I follow with debug and see that it gets the document, but when it leaves the function it does not pass the doc to the main program. The last line of the function before End Function is: GetUserDoc=Doc
I can see in Debug that GetUserDoc is populated with the document I want, but when it transferrs back to the calling program the variable that is set equal to GetUserDoc is empty. There is a Use statement in the Global Options of the form I am calling the function from that references the script library that the function is in.
I had this problem before, but thought I cured it by moving the Use statement to the Global Options for the form. Any Ideas?
MJ
Subject: Problems with LS function that returns a NotesDocument
Your problem is, that a NotesDocument- object can NOT exist without the corresponding NotesDatabase- Object.
You HAVE TO declare the Database you get your NotesDocument from in “globals”, otherwise your NotesDocument will always turn into “nothing” after leaving the Function where the NotesDatabase- object is declared.
I’m sorry, my english is a bit weird, but I hope you understand what I mean.
Torsten
Subject: Problems with LS function that returns a NotesDocument
your function should look something like this (Note the “set”):
Function getDocumentByKey (db As Notesdatabase, viewGet As NotesView, key As String) As NotesDocument
Dim docGetBykey As NotesDocument
Set docgetByKey=viewGet.GetDocumentByKey(key)
Set getDocumentByKey = docGetByKey
End Function
and call it with something like:
Dim docGet As NotesDocument
Set docGet=getDocumentByKey (db, viewGet, Key)
The lack of “Set” at the end of the function is what got you.
In this example I call the function from a Script Library subroutine and I pass the db to the function.