Assign field's lookup SELECT dynamically?

Hi

I have a field on a form that is of type SELECT.

The recordset this field lists in its drop down needs to be slightly different, depending on whether the form is inserting a new record, or updating an existing record.

So - is it possible to change the field’s lookup SELECT value dynamically in either the BeforeInsert and BeforeUpdate events? And if so, how?

Thanks

Unfortunately the onbefore event is executed just before the real statement so this event is useless for this purpose. Somehow you need to adjust the elements depending on the status of your application. You can set a global variable behind the where statement. I sometime use the sql in statement to subselect from a pool. I’m not sure though how to intercept the change of status, never tried that.

In addition to Albert’s suggestion with the global variable in the WHERE statement you might want to try the sc_btn_new macro in the onLoad event.
With it you can check if the ‘Add’ button has been clicked and set your variable for the SQL statement.

jsb

[QUOTE=jsbinca;26855]In addition to Albert’s suggestion with the global variable in the WHERE statement you might want to try the sc_btn_new macro in the onLoad event.
With it you can check if the ‘Add’ button has been clicked and set your variable for the SQL statement.

jsb[/QUOTE]

Ah, the onload event is triggered too if you click insert. That’s good to know.

Thanks both

I had tried replacing the field’s SELECT in the lookup section with just a [global] variable that contained the whole SQL statement, but that didn’t work.

I’ll your suggestions a try.

:slight_smile:

Yep - got it working. Thanks guys!