Rich Text and GetDocumentByKey

I have a field on a form that needs to lookup to a view in another database (which happens to be rich text)and place the contents in this field and it needs to be editable.This is the code I’ve done:

Sub Exiting(Source As Field)

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument    

Dim NAQ As String

Dim db As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument

Dim docA As NotesDocument

Dim rtitemA As Variant

Set uidoc = workspace.CurrentDocument    

NAQ = uidoc.FieldGetText( "SvcName" )

Set db = New NotesDatabase( "mercury/Walker", "ClientServices\BestPractices.nsf" )

Set view = db.GetView( "NAQs Only" )

Set doc = view.GetDocumentByKey( NAQ )

Set docA = doc.Document

Set rtitemA = docA.GetFirstItem("Body")

Call uidoc.FieldSetText _

( "PNAQ", docA.rtitemA( 0 ) )

End Sub

It’s not working…I get “Type Mismatch” on the Set docA=doc.Document line. Not sure how I can get this to work the way I want.

Any help is appreciated.

Subject: Rich Text and GetDocumentByKey

doc is already a NotesDocument, so there’s no need to create docA. Eliminate the line where you try to instantiate docA and replace docA with doc for the rest o the script.

…oh, and the FieldSetText line won’t work if Body is indeed a rich text field. Look into the NotesRichTextItem class for what you’ll need to manipulate rich text fields programmatically (executive summary: it’s a pain and you can only really do it in the back end, not in an open document).