[SOLUTION] Use a global variable in lookup based on value of another field

The form has 3 fields - all use a lookup

STEP 1. Define the 1st field and its choices (this can be either manual or automatic)
Fieldname = transtype - choices are Deposit / Withdraw

STEP 2. Create an OnChange Ajax Event for the 1st field (this is where you define your variables; note that they have to be global - a local variable will not work)
//Set query for account lookup
if ({transtype} == ‘Deposit’)
{
$acct1_type=‘Income’ ;
$acct2_type=‘Asset’ ;
sc_set_global($acct1_type) ;
sc_set_global($acct2_type);
}
else
{
$acct1_type=‘Asset’ ;
$acct2_type=‘Expense’ ;
sc_set_global($acct1_type) ;
sc_set_global($acct2_type);
}

STEP 3. Application > Global Variables … set those variables to OUT (acct1_type & acct2_type)

STEP 4. Define the 2nd & 3rd fields (account1 & account2) - use a Select statement with the global variable to define their choices
SELECT account_id, account_id
FROM account
WHERE account_type = ‘[acct1_type]’
ORDER BY account_id

STEP 5. On the 1st field - (Ajax Processsing) [SIZE=12px] “[/SIZE][SIZE=12px]Use AJAX to reload other fields of type Select,…”.[/SIZE][SIZE=12px] [/SIZE] - reload the values of the 2nd field (account1 and account2)

betty

Thanks for sharing your solution.

Spoke too soon … If I go back through my records - although it set the value in the database - on the scriptcase form it shows that value is empty.