Programatically choose default for "select" field

Is it possible to programatically set a default for a “select” field?

I have a select field that is loaded from the database, but I want the last used value to be the default next time the user goes to my form. I can save the value in the database, but am trying to figure out how to set the default to it when they come back in.

Thanks

Re: Programatically choose default for “select” field

i had a similar problem, if i read that right. i have a select field, and i needed it to default to a certain value(onInsert). if you know what that value needs to be then in the onLoad put this:

if(sc_btn_new){
     {field} = value;
}

Of course, you need to change what the field is and what value it should have.

Re: Programatically choose default for “select” field

This is a control form I’m really using for searching, so I don’t have a new button, at least not that I know of.

If I could set the Title and value via the value in a field I could make it work, but it doesn’t appear as though that can be done.

I can’t put {field} in the Title of the “select” data type for the Lookup and get it to work.

Re: Programatically choose default for “select” field

created a control form
created a select field

select state_code,state_name
FROM state_codes
ORDER BY state_code

onLoad:
{input_select} = ‘FL’;

run:
Select Field shows ‘Florida’

Scott.

Re: Programatically choose default for “select” field

thats what i was going to say, if there is no new button, dont check for anything just set the field’s value.

Re: Programatically choose default for “select” field

I could have sworn that I tried that first, but your test does seem to work just fine.

I will go back and put it in my app and see what it does.

Thanks