At times it can be useful to execute some code when a radio button or checkbox is selected. However, in the Notes client there is currently no way to respond to the onClick, onChange, or onSelect event of one of these elements.
To work around this, create a radio button or checkbox field and set it to "Refresh fields on keyword change." Next, in the Postrecalc event of the form (this will require LotusScript) place a check for the currently selected field. This is done using the NotesUIDocument.CurrentField property. When this property contains your field name, execute your code.
The disadvantage is that your code will run whenever the document is refreshed and your radio button/checkbox field has the focus (a workaround can be put in place so that code will not execute if the field had focus the last time it ran).
To use the code below, create two fields, one checkbox named "chkFoo" and one radio button field named "rdoFoo." Set both fields to "Refresh fields on keyword change" and paste the code into the Postrecalc event of the form.
Sub Postrecalc(Source As Notesuidocument) %REM ***************************************** Since the Notes client doesn't respect the onClick, onChange, or onSelect events of a keyword field this function acts as a delegate for controlling these events via a document refresh. Created by Jordan Matthiesen, GWI Software %ENDREM ************************************** Dim strCurField strCurField = Source.CurrentField Select Case strCurField Case "chkFoo": Msgbox "Checkbox checked, item selected: " & Source.FieldGetText( strCurField ) Case "rdoFoo": Msgbox "Radio button checked, item selected: " & Source.FieldGetText( strCurField ) End Select End Sub
This was first published in July 2001