Announcement

Collapse
No announcement yet.

How to get a dropdown list to start at a specific record

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

  • How to get a dropdown list to start at a specific record

    Hi All,

    I have a control app that has one dropdown box which displays a number of rows based on "dates from and to" This data is from a table, and displays in the dropdown list perfectly fine, except that I want the drop down list to initially display a specific row based on todays date. It always starts with the first record, and not the one I want to display.

    I have some code in the application init event that locates the id number of the record, but I cannot seem to get the dropdown list to display this row.

    I allocated the id number (integer) to a variable and noted this variable in the initial value field. The single field in the window is an integer, set to select, so the field can use an automatic lookup the records. I need all the records to be available, I just want the window to display one specific one on startup of the app.

    I am probably just missing one small thing but I cannot seem to locate it.

    Any suggestions?

  • #2
    First record should be today, and others are greater than? Maybe yoiu forgot order by?
    /Giuseppe

    Professional Scriptcase Services
    Some Customers opinions

    Comment


    • #3
      The list is so you report on transactions between two set dates, both in the past and also the future and of course today.

      The SQL for the select is

      SELECT bd_id, sc_concat(bd_desc," - ", bd_datefrom," to ", bd_dateto)
      FROM basdates
      ORDER BY bd_id

      There are about 35 rows returned starting with "Qtr 1 2013 - 2012-07-01 to 2012-09-30"
      then "Qtr 2 2013 - 2012-10-01 to 2012-12-31" and each of the other rows describes the next quarter period until it ends with something like "Qtr 4 - 2020-04-01 to 2020-06-30"

      I have code in the applicationinit event that has determined that today's date falls into say row 14. It is that row (row 14 and not row 1) that I wish to have displayed when the application opens, but of course I still need all of the rows to be available for selection.

      Does that make it a little clearer?

      Thanks

      Tony

      Comment


      • #4
        code the condition in your onload event.

        query the value you need for example

        [php]
        $sql= "SELECT <idfield> FROM basdates WHERE <mydate> between <first date> and <lastdate>"
        sc_lookup( val, $sql );

        if ( isset( {val[0][0]} ) )
        {
        {myListfield} = {val[0][0]};
        }
        [php]

        that should do it.

        Regards

        Comment


        • #5
          Thanks kafecadm,

          I had the same lookup code as you mentioned but instead of using the {myListfield} = {val[0][0]}; I used an intermediary variable and placed that variable name in the initial value setting for the field. So, now that I have placed the code in the correct event, and given the {myfield} it's value directly, it all works a treat.

          A very good start to the day.

          See ya

          Tony

          Comment


          • #6
            Good to know so... keep the hard work on =D

            Comment

            Working...
            X