Form events in the Events developer sample form

Microsoft Office InfoPath

Show All Show All

Form events in the Events developer sample form

The Events developer sample form implements a variety of Microsoft Office InfoPath 2003 form events that can be used to respond to specific activities that occur when a form is opened and while it is being filled out. Form events can occur when a form's version number is validated, when a form is opened, when a form view is changed, and after a form has been merged with another form.

The following table lists each of the form events implemented in the Events developer sample form, along with a description of how they are used.

Event Description
OnVersionUpgrade Used to verify that the version number of the form being opened matches the version number of the form when it was originally designed. If the version numbers do not match, this event occurs and scripting code can be used to update the form or display an error message.
OnLoad Used to initialize the form as it is being opened. When this event occurs, scripting code can be used to set the appropriate view based on data contained in the form.
OnSwitchView Used when changing from one view to another. This event occurs when a user changes views, and scripting code can be used to insert data into the form.
OnAfterImport Used to provide additional processing after a form has been merged with another form. This event occurs after data is imported from another form, and scripting code can be used to set the appropriate view based on the merged data contained in the form.

Note  The OnSubmitRequest event is also a form event, but it was not used in the Events developer sample form.

ShowUsing the OnVersionUpgrade event

ShowUsing the OnLoad event

ShowUsing the OnSwitchView event

ShowUsing the OnAfterImport event