SetActionCode

Description

Sets the action code for an event in a DataWindow control. The action code determines the action that PowerBuilder takes following the event. The default action code is 0.

NoteWhere to use SetActionCode SetActionCode is obsolete in PowerBuilder. To return a value, include a RETURN statement in the event script using the return codes documented for that event.

For the Web ActiveX, use SetActionCode for event return values.

Applies to

DataWindow type

Method applies to

PowerBuilder

DataWindow control, DataWindowChild object

Web ActiveX

DataWindow control, DataWindowChild object

Syntax

PowerBuilder

integer dwcontrol.SetActionCode ( long code )

Web ActiveX

number dwcontrol.SetActionCode ( number code ) 

Argument

Description

dwcontrol

A reference to a DataWindow control or child DataWindow.

code

A value specifying the action you want to take in the DataWindow control. The meaning of the action code depends on the event.

Returns

Returns 1 if it succeeds and –1 if an error occurs. If any argument’s value is null, SetActionCode returns null.

Usage

Use SetActionCode to change the action that occurs following a DataWindow event. Not all DataWindow events have action codes, only those events that can have different outcomes.

NoteSetActionCode last statement in script Although SetActionCode is not required to be the last statement in a script, it may not perform as expected if other statements follow it.

Examples

Example 1

In the ItemChanged event script for dw_Employee, these statements set the action code in dw_Employee to reject data that is less than the employee’s age:

integer a, age

age = Integer(sle_Age.Text)

a = Integer(dw_Employee.GetText())

IF a < age THEN dw_Employee.SetActionCode(1)

Example 2

This example shows a script for the DBError event script that displays a version of the error message to the user. Because PowerBuilder also displays a message to the user after the event, the script calls SetActionCode to set the action code to 1, which suppresses the PowerBuilder error message:

integer errnum

errnum = dw_emp.DBErrorCode()


// Show error code and message to the user

MessageBox("Database Error", &

		"Number " + String(errnum) + " " + &

		dw_emp.DBErrorMessage(), StopSign!)


// Stop PowerBuilder from displaying its message

dw_emp.SetActionCode(1)