Very strange screen redrawing problem

I have a very unusual problem which is causing no end of trouble, I hope someone can offer me some insight into solving it.

I have the following code on a button:

Dim UIWS As NotesUIWorkspace

Dim UIDoc As NotesUIDocument

Dim LeaseRenewalDoc As NotesDocument

Set UIWS = New NotesUIWorkspace

'Specify no target frame.

UIWS.SetTargetFrame(“”)

'Compose document.

Set UIDoc = UIWS.ComposeDocument(“”, “”, “Lease Renewal Profile”)

Set LeaseRenewalDoc = UIDoc.Document

'Populate fields.

LeaseRenewalDoc.Test1 = “Test1”

LeaseRenewalDoc.Test2 = “Test2”

(Really I want to do a bit more than assign two simple strings, but I’ve reduced it to this to try and solve the problem).

The problem is that only the first value will consistently appear. The second value will appear, but then when I manipulate other things on the form (totally unrelated fields, tables etc.) it suddenly stops appearing. Even stranger, if I open an instance of Notepad, reduced to be quite small, and actually drag it over the fields on my notes document, the value will then appear!

I have tested the code on different machines, with the following results:

Notes 6.5 & Windows XP - Problem encountered

Notes 6.5 & Windows 2K - Problem encountered

Notes 6.0 & Windows XP - Problem encountered

Notes 6.0 & Windows 2K - Works perfectly!

Can anybody help? This is driving me insane!!

Subject: Try creating the document first

I would suggest that you create a backend document (NotesDocument not NotesUIDocument), assign it any values, and then open that document in the workspace using the EditDocument method of NotesUIWorkspace.