PowerBuilder · Runtime error

R0002: Null object reference

What does R0002: Null object reference mean in PowerBuilder?

The application referenced a property or method on an object reference that is currently null, commonly a DataWindow control or DataStore that was never assigned an actual DataWindow object, only declared.

R0002: Null object referencePowerBuilder Classic · Appeon PowerBuilder

Condition

The application referenced a property or method on an object reference that is currently null, commonly a DataWindow control or DataStore that was never assigned an actual DataWindow object, only declared.

Fix

Confirm the DataWindow object was actually created and assigned before use, not just declared. A DataStore or DataWindow control is a container; it needs SetTransObject and an actual dataobject assignment, or a call like Create(), before its properties and data can be referenced. This is the single most common runtime error reported in PowerBuilder forums, and it is thrown by the NullObjectError system exception class specifically so it can be caught separately from other runtime errors.

Pending source verification. Not yet checked against official documentation.

Related runtime error