Previous Topic

Next Topic

Book Contents

Book Index

Form Designer Component Events

Navigator > Setup > Form Designer > Layout tab > Events tab

Components in the Form Designer have events, depending on the component type. These are listed in the Component panel, Events tab.

Click Lookup Code beside an event to locate the Sub procedure in the Code tab. If a Sub procedure has not been assigned a Sub will automatically be appended and assigned to the event. The naming convention is Event name if the component is "Self", or ComponentName_EventName.

Click to select from the available Sub procedures.

See also Events Sequences to see the order events are triggered in relation to other events.

Event

Description

AfterSave

Occurs after a record is saved to the table.

Sub AfterSave(Sender as Object)

AfterScroll

Occurs when the currently selected row in a table or memory table is changed.

Sub AfterScroll(Sender as Object)

BeforeClose

Occurs before a form or live edit grid is closed.

Sub BeforeClose(Sender as Object)

BeforeSave

Occurs before a record is saved to the table.

Sub BeforeSave(Sender as Object)

FieldAfterChange

Occurs after a field is changed when a row is being posted to a table. Field Events are dynamic events that are based on fields in the table, they are only available for Custom tables and Memory tables.

Sub FieldAfterChange(Sender as Object, OldValue as Object)

FieldBeforeChange

Occurs before the field is changed when a row is being posted to the table. You can replace the value for the field by setting the NewValue parameter. Field Events are dynamic events that are based on fields in the table, they are only available for Custom tables and Memory tables.

Sub FieldBeforeChange(Sender as Object, ByRef NewValue as Object)

OnActivate

For the Form object, occurs when a form is activated.

Sub OnChange(Sender as Object)

OnAfterChange

Occurs after the text for the edit component has changed.

Sub OnAfterChange(Sender as Object, OldValue as Object, NewValue as Object)

OnBeforeChange

Occurs before the text for the edit component is about to change. You can replace the value for the Edit component by setting the NewValue parameter.

Sub OnBeforeChange(Sender as Object, OldValue as Object, ByRef NewValue as Object)

OnBtnClick

Occurs when the user clicks on a button in a grid navigator. The button identifier for use in the code is the name listed in the Properties Tab > Visible Buttons.

Set the Handled parameter to true to stop further processing of the button click.

Sub OnBtnClick(Sender as Object, Button as Number, ByRef Handled as Boolean)

OnCalcCellColors

Changes the colours of the grid cells when a cell is calculated. Only available for grids.

Sub OnCalcCellColors(Sender as Object, Field as Object, Row as Number, Highlight as Boolean, CellFont as Object, ByRef BackColor as Number)

OnCanDelete

OnCanInsert

OnCanModify

These memory table events can be used to control per row behavior. For example, if a row can be deleted based on some criteria, this logic can be added to the OnCanDelete event. Same with the OnCanModify and OnCanInsert. FD grid Navigators also fire these events based on keyboard shortcuts e.g when F3 on a grid is pressed or the Delete button is clicked, then the OnCanDelete event is triggered for the memory table bound to the grid. The Afterscroll event also triggers these events.

All three methods have the following signature

Method(Sender as Object, ByRef Allowed as Boolean)

e.g. If a memory table row can be deleted, provided it's inactive column is set to false, then the event implementation would look like this

Sub OnCanDelete(Sender as Object, ByRef CanDelete as Boolean)

CanDelete = MemTable.Inactive = False

End Sub

e.g.2. If Insert within the grid is only allowed based on a global variable called InsertMode

Sub OnCanInsert(Sender as Object, ByRef CanInsert as Boolean)

CanInsert = InsertMode

End Sub

Since these events get triggered so often, it is a good idea to keep the logic as simple as possible to avoid painting issues and flicker.

OnChange

Occurs when the text for the edit component may have changed.

Sub OnChange(Sender as Object)

OnClick

Occurs when the user clicks the component.

Sub OnClick(Sender as Object)

OnClose

Occurs when the form closes.

Sub OnClose(Sender as Object)

OnCloseQuery

Occurs when the form attempts to close. Set the CanClose parameter to true to allow the Form to close.

Sub OnCloseQuery(Sender as Object, ByRef CanClose as Boolean)

OnCreate

Occurs when the form is created.

Sub OnCreate(Sender as Object)

OnDblClick

Occurs when the user double-clicks the left mouse button when the mouse pointer is over the component.

Sub OnDblClick(Sender as Object)

OnDeactivate

For the Form object, occurs when a form is deactivated.

Important: Do not make any changes to the focus in an OnDeactivate event. Focus must be controlled by the event.

Sub OnDeactivate(Sender as Object)

OnDestroy

Occurs when the form is destroyed.

Sub OnDestroy(Sender as Object)

OnEnter

Occurs when a component receives the input focus.

Sub OnEnter(Sender as Object)

OnExit

Occurs when the input focus shifts away from one component to another.

Sub OnExit(Sender as Object)

OnNewRecord

Occurs after a new record has been added to the table.

Sub OnNewRecord(Sender as Object)

OnNewValueEntered

Occurs when a new value (text) is entered into a drop down list.

Sub OnNewValueEntered(Sender as Object)

OnShow

Occurs when the form is shown.

Sub OnShow(Sender as Object)

OnTabChange

Occurs after the cursor position has changed from one row to another.

Sub OnTabChange(Sender as Object)

OnValueEntered

Occurs when a value (text) is set in a combo.

Sub OnValueEntered(Sender as Object)