GetChild – PB Docs 126

GetChild method (DataWindows)


Provides a reference to a child DataWindow or to a report
in a composite DataWindow, which you can use in DataWindow functions
to manipulate that DataWindow or report.


DataWindow type

Method applies to


DataWindow control, DataStore object

Web ActiveX

DataWindow control



[Web ActiveX]




A reference to the DataWindow control
or DataStore that contains the child DataWindow or report.


A string that names the column containing
the child DataWindow or that names the report in the composite DataWindow.


A variable in which you want to store
the reference to the child DataWindow or report. For the Web ActiveX,
the separate function GetChildObject must be called to get the reference
variable to the child object.

Return Values

Returns 1 if it succeeds and –1 if an error occurs—for
example, if the child object does not exist.

If any argument is null, in PowerBuilder and JavaScript the
method returns null.


A child DataWindow is a DropDownDataWindow in a DataWindow object.

A report is a DataWindow that is part of a composite DataWindow.
A report is read-only. When you define the composite DataWindow
in the DataWindow painter, each report is given a name. You can
see the name in the Name option of the Properties view. You must
use the report name (not the name of the DataWindow object in which
the report has been placed) when calling GetChild.

Use GetChild when you need to explicitly
retrieve data for a child DataWindow or report. Although PowerBuilder
automatically retrieves data for the child or report when the main
DataWindow is displayed, you need to explicitly retrieve data when
there are retrieval arguments or when conditions change and you
want to retrieve new rows.

When you insert a row or retrieve data in the main DataWindow, PowerBuilder
automatically retrieves data for the child DataWindow. If the child
DataWindow has retrieval arguments, PowerBuilder displays a dialog
box asking the user for values for those arguments. To suppress
the dialog box, you can explicitly retrieve data for the child before
changing the main DataWindow (see the example).

note.png Nested reports

You cannot use GetChild to get a reference
to a report in a composite DataWindow when the report itself is
a composite or nested DataWindow.

Changing property values with the Modify method
can cause the reference returned by GetChild to become invalid.
After setting such a property, call GetChild again.
If a property causes this behavior, this is noted in its description
in Chapter
38, “DataWindow Object Properties.”


This example retrieves data for the child DataWindow
associated with the column emp_state before retrieving
data in the main DataWindow. The child DataWindow expects a region
value as a retrieval argument. Because you populate the child DataWindow
first, specifying a value for its retrieval argument, there is no
need for PowerBuilder to display the retrieval argument dialog box:

In a composite DataWindow there are two reports:
orders and current inventory. The orders report has a retrieval
argument for selecting the order status. This report displays open
orders. The composite DataWindow is displayed in a DataWindow control
called dw_news and the reports are named open_orders
and current_inv. The following code in the Open event of
the window that contains dw_news provides a retrieval argument
for open_orders:

The following example for the Web ActiveX displays
the reference to the child object in a message box:

See Also

Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x