Please help a novice on a (maybe) simple problem -- thank you very much

Below is a section of code I copied from the Help file under “Examples: AppendTable method”. I though that I could create a form, add a button and place the code section, open the form in Lotus Note, and click the button – then I’d see a table on the form. The actual result is that the form showed nothing. I traced through the code, not error was generated at any line. I believe that I missed something very simple and very important.

  1. This view action creates a basic auto-width table of 4 rows and 3 columns, and populates it.

Sub Click(Source As Button)

Dim session As New NotesSession

Dim db As NotesDatabase

Set db = session.CurrentDatabase

REM Create document with Body rich text item

Dim doc As New NotesDocument(db)

Call doc.ReplaceItemValue(“Form”, “Main topic”)

Call doc.ReplaceItemValue(“Subject”, “Table 4 x 3”)

Dim body As New NotesRichTextItem(doc, “Body”)

REM Create table in Body item

rowCount% = 4

columnCount% = 3

Call body.AppendTable(rowCount%, columnCount%)

REM Populate table

Dim rtnav As NotesRichTextNavigator

Set rtnav = body.CreateNavigator

Call rtnav.FindFirstElement(RTELEM_TYPE_TABLECELL)

For iRow% = 1 To 4 Step 1

For iColumn% = 1 To 3 Step 1

  Call body.BeginInsert(rtnav)

  Call body.AppendText("Row " & iRow% & ", Column " & iColumn%)

  Call body.EndInsert

  Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)

Next

Next

REM Save document and refresh view

Call doc.Save(True, False)

Dim ws As New NotesUIWorkspace

Call ws.ViewRefresh

End Sub

Subject: Please help a novice on a (maybe) simple problem – thank you very much

The code creates a document in the back end; it doesn’t update a currently open document. You should put the code in a view action button instead of on a form.

Also, the document created uses a form called “Main topic” which has a Rich Text Item called “Body”. It looks like this code is meant to be run in a database based on the discussion template. If your database is not based on this template, you will have to create the form yourself and a view to display the documents using this form. If you run the code from an action in this view, a new document should appear which will have the table there…

Hope this helps.

E

Subject: RE: Please help a novice on a (maybe) simple problem – thank you very much

Thanks!

–JL