Try using a function instead of an expression. Also you can inspect the values of your variables by hovering over the variable itself, or using the show() command and looking at the log window.
On_OK = function({curr_days},
sql_statement = evalinsert(
"Select *
from DATABASE A
WHERE A.SCANDATETIME > (SYSDATE - ^curr_days^)");
show(curr_days, sql_statement);
Open Database("DSN=xxx;UID=xxxxx;PWD=xxxxx;", sql_statement, "Table1");
);
ui = New Window( "Choose an option",
<<Modal,
V List Box(
Text Box( "Query Last 'x' Number of days:" ),
Spacer Box( Size( 20, 20 ) ),
days = number Edit Box( "" )
),
Button Box( "Ok",
current_days = days << Get;
On_OK(current_days);
),
);