I just started Notes development and I'm having a few problems. I am trying to read the value of a field when the document is opened, but I can't understand why I am getting an error. In a form's Initialize event I am using the code:
Messagebox "Initializing Form"
Dim workspace As New NotesUIWorkspace
Dim doc As NotesUIDocument
Set doc = workspace.CurrentDocument
Dim txtMessage As String
txtMessage = doc.FieldGetText("NumberField")
Messagebox "The document is " & txtMessage
And I get the error "Notes error - cannot locate field". The field is in the form, so I can't figure out why Notes cannot locate it. Do the fields not exist in the Initialize sub? When I place the same code in the field's Initialize sub, I get "Object variable not set" because Doc is nothing, but in the form's Initialize sub Doc is set to the new document.
Can someone explain what is going on to me?