Execute code when a radio button or checkbox is selected

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

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.