SetActionCode (obsolete)


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.

Where 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.

Applies to

DataWindow type

Method applies to


DataWindow control, DataWindowChild object



integer dwcontrol.SetActionCode ( long code )




A reference to a DataWindow control or child DataWindow.


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

Return value

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


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.

SetActionCode 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.


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)

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