Attention: Visual Basic Gurus

I am assuming if you are reading this that you know VB pretty well and are familiar with Domino Objects and manipulating them from VB. Any help you can give would be greatly appreciated!

We have a VB application that needs to open a document held in a notes database for the users review. The VB app. Supplies this function with a string (Key) and this function then opens the Notes client, presents the user with a list of matching documents (matching the supplied Key), allows the user to choose one document (Here lies the problem), and opens the chosen document in the UI in read only mode.

The function works great up to the point marked with a “>>>>>”. We are receiving the error “Object expected” for the line:

“Set uidoc = space.EDITDOCUMENT(False, doc2) 'open found document in read mode”

Doc2 is equal to the UNID of the chosen document in the picklist, but VB is not seeing it as a NotesDocument even though it is Dimmed that way.

We have been playing around with early and late binding as you can see. We will switch the way the session is build so as not to ask for the password if an instance of Notes is already running after we get the code working.

Take a look and let me know what you think!

Thank you!!!

JB Dunmyer

Code follows:

Public Function LSLookUp(ByVal strAcctNum As String) As Long

'Dim s As Object

’ Dim db As Object

’ Dim doc As Object

’ Dim dc As Object

’ Dim view As Object

’ Dim uidoc As Object

Dim space As Object

Dim db As NotesDatabase

Dim s As New NotesSession

Dim doc As NotesDocument

Dim doc2 As NotesDocument

Dim dc As New NotesDocumentCollection

'Dim space As NOTESUIWORKSPACE

Dim view As NotesView

Dim uidoc As NOTESUIDOCUMENT

Dim unid As Variant

's and db declared in general as object

'Set s = CreateObject(“Notes.Notessession”) 'create session

s.Initialize

Set db = s.GetDatabase(“Domino”, “dept\LoanServ\LSdoclib.nsf”) 'Loan Servicing Document Library on Domino

Set view = db.GetView(“(PLUS1)”) ’ get Account Number View

Set doc = view.GetDocumentByKey(strAcctNum)

If doc Is Nothing Then 'If no document is found for this account number

LSLookUp = 0 'Return a False

Exit Function

End If

Set space = CreateObject(“Notes.NotesUIWorkspace”) 'set workspace

'Set dc = CreateObject(“Notes.NotesDocumentCollection”) 'set document collection

AppActivate “Lotus Notes”, False

unid = space.PICKLISTSTRINGS(3, False, “Domino”, “dept\LoanServ\LSdoclib.nsf”, “(PLUS2)”, “View Loan Servicing Document”, “Choose a Loan Servicing Document to view below”, 4, strAcctNum)

If unid(0) = “” Then

LSLookUp = 2 'Return No Document Selected Error

Exit Function

End If

Set doc2 = db.GetDocumentByUNID(unid(0))

If doc2 Is Nothing Then Exit Function

'Set doc = dc.GetFirstDocument

Set uidoc = space.EDITDOCUMENT(False, doc2) 'open found document in read mode

Set s = Nothing 'Kill objects to free memory

Set db = Nothing

Set doc = Nothing

Set space = Nothing

LSLookUp = 1

End Function

Subject: Maybe this is your problem …

You look up the unid of the document in the view ‘(PLUS2)’, 4th column, right?

Is suppose you use the @DocumentUniqueID function to show the unid of the documents in the 4th column…

Well the @DocumentUniqueID function does NOT return a string, but something calles ‘Special text’. Change the formula to :

@Text(@DocumentUniqueID)

or

@Text(FieldName) if you have stored the unid in a field.

Just a guess, I’m not sure this will help you out

Subject: RE: Maybe this is your problem …

Thank you Joris!

I will try your suggestions and let you know here how they turn out!

JB Dunmyer

Subject: This solution is better …

I don’t understand why use the walk-around with the documentunid… Why don’t you directly select the needed document? It makes the code more efficient and simpler. It just takes some minor changes :

dim docs as notesdocumentcollection

set docs = space.PICKLISTCOLLECTION(3, False, “Domino”, “dept\LoanServ\LSdoclib.nsf”, “(PLUS2)”, “View Loan Servicing Document”, “Choose a Loan Servicing Document to view below”)

If docs.count=0 Then

LSLookUp = 2 'Return No Document Selected Error

Exit Function

End If

Set doc2 = docs.getfirstdocument

If doc2 Is Nothing Then Exit Function

Set uidoc = space.EDITDOCUMENT(False, doc2) 'open found document in read mode