Announcement

Collapse
No announcement yet.

Assign field's lookup SELECT dynamically?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    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.
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      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

      Comment


      • #4
        Originally posted by jsbinca View Post
        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
        Ah, the onload event is triggered too if you click insert. That's good to know.
        Albert Drent
        aducom software netherlands
        scriptcase partner, reseller, support and (turn-key) development
        www.scriptcase.eu / www.scriptcase.nl

        Comment


        • #5
          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.

          :-)

          Comment


          • #6
            Yep - got it working. Thanks guys!

            Comment

            Working...
            X