Search code examples
lotus-noteslotus

Get the value of a field in a Lotus Notes Form


I need help, I need to know how can I get the value of a field of a form I know how to get the field name but not the value in it... Here's a trunked version of my code: By the way, the loop make no sense for now but it will be used properly once I found how to get the fields values,... Thank you all!!

Forall field In form.Fields     
    fieldCount = fieldCount + 1
    msgString = msgString & Chr(10) &   "     " & field

    If (field  Like "*Act*")  Then          
        ActfieldCount = ActfieldCount + 1

        If (field  Like "RNomAct1")  Then
            Msgbox("RNomAct1 found in SourceString!")
'thoses do not work             

'               test = field.GetItemValue("RNomAct1")   
'               test = field.FieldGetText("RNomAct1")   
'               Messagebox( test( 0 ) )

        End If
    Else
        Msgbox("Could not find the SearchString.")
    End If

End Forall

Solution

  • Somewhere you should have a reference to a document. Or if you don't you can access the current document via some other objects:

    Dim ws as New NotesUIWorkspace
    Dim uidoc as NotesUIDocument
    Set uidoc = ws.CurrentDocument
    

    Then you can get the field value with this call:

    uidoc.FieldGetText("name-of-field-here")