How to check if a search for a table row is successful

I am looking for a table row to retrieve some column values.
The table row may or may not be there.
How do I code to check if the ‘findRow’ is successful?
Currrently I get an error ‘NullPointerException’ in the coding line after ‘findRow’ if the table row is not found (code attached below). Thanks for help with this.

TableRow row2=t_02.findRow(v_sdt,“Start date-time”);
Float v_steps=row2.getFloat(“Steps”);

Yeah, just check

TableRow row2=t_02.findRow(v_sdt, "Start date-time");
if (row2 != null) {
    Float v_steps=row2.getFloat("Steps");
    failed = true; 


when you use v_steps later, move this section inside the if-clause also
or evaluate failed to avoid errors caused by v_steps.

v_steps is only known inside the { } so you might want to define v_steps before the if(row2 != null) {..


Coding resolved, thank you.

1 Like