Subject: RE: retrieve field value from document in other db
Since you don’t have any error-trapping, I’m guessing you’re not aware that this line:
Set doc = db.GetDocumentByUNID(unid)
is erroring out because you haven’t actually opened db. (There are certain things you can do with an unopened database, like get its name or path, but you can’t get a view or document until the database is open.) You could handle this two ways:
Dim db as new notesdatabase(“”, “”)
Set db = session.getdatabase(“server”, “database.nsf”)
or 2)
Dim db as new notesdatabase(“server”, “database.nsf”)
call db.Open(“”, “”)
FYI, I’d recommend adding error-trapping to your code as a best practice.
Sub Click(Source As Button)
on error goto errhand
Dim session As New NotesSession
Dim db As New NotesDatabase (“SERVER”,“DATABASE.nsf”)
Dim ws As New NotesUIWorkspace
Dim thisUIdoc As NotesUIDocument
Dim doc As NotesDocument
Dim tinum As String
Set thisUIdoc = ws.CurrentDocument
unid = thisUIdoc.FieldGetText(“TIID”)
Call db.Open(“”, “”)
Set doc = db.GetDocumentByUNID(unid)
tinum = doc.GetItemValue(“OrderNumber1”)
Messagebox(tinum)
exit sub
errhand:
msgbox "Error at line " & erl & ": " & error
exit sub
End Sub