Property from dataset

Is this the problem? It's initially using the previous step number in the where condition of the query?

Perhaps save the window with the default value in the text editor, and use scripting to populate the data instead of a binding.

Example:

# Updates the value only when the step number changes
# Assumes there is a custom property on the text field called myCurrStepNum,
# ...and that the step num is updated automatically in some way
if event.propertyName == 'myCurrStepNum' and event.newValue is not None:
	query = 'SELECT safety FROM tasks WHERE stepnumber = ?'
	event.source.text = system.db.runScalarPrepQuery(query, [event.newValue], 'NameOFDatabase')