11 Replies Latest reply on Mar 25, 2013 2:56 PM by rd_hughes

    Scrolling to a specific record...

      Hope someone can help me with this...

       

      I have a very basic "calendar" table. It simply lists events in reverse chronological order, displaying both past and future events.

       

      What I would like to be able to do is scroll to / go to "today's date", whilst continuing to show all records.

       

      I've tried a few different things, all without success. Am I missing something obvious?

       

      I hope I've explained this clearly enough, and any help would be greatly appreciated!

        • 1. Re: Scrolling to a specific record...
          mikebeargie

          a very dirty way of doing it would be:

           

          Sort Records - Date - ASC

          Go To Record - First

          Loop

             Exit Loop If - table::dateField => Get(CurrentDate)

             Go To Record - Next (exit after last)

          End Loop

           

          This would go through all the records, starting from the oldest one, and stop whenever it met a record that had today's date (or later, if not today).

           

          There's probably a more elegant solution.

          1 of 1 people found this helpful
          • 2. Re: Scrolling to a specific record...
            debi

            rd_hughes,

             

            A couple of other options:

             

            A. You could count the number of records with a date larger than today (through a relationship or, if you're using v12, using the ExecuteSQL function). Then use the Go to Record/Request/Page script step with a calculation (count + 1).

             

            B. Find for today, then Show All Records. Your current record will still be one of the first found set.

             

            Debi Rubel

            FullCity Consulting

            • 3. Re: Scrolling to a specific record...

              Hi Mike,

               

              Thanks for the very quick response.

               

              I think your solution is close, but not quite right. If I enter >= it go to any records that is today or later... Which could be six months from now. If you see what I mean?

               

              I need it to go to "today", or the closest day that has an entry, even if there are hundreds of records beyond.

               

              Like I say, I'm sure your solution is very close to what I need. Have you any further suggestions?

               

              David

              • 4. Re: Scrolling to a specific record...

                Hi Debi,

                 

                Thanks for your response also.

                 

                A. I'll definitely try this, thanks. I've not used the ExecuteSQL function before, but I'll look into it.

                 

                B. A similar situation to Mike suggestion, I think. There won't necessarily be an entry for "today", so I need a script that can find "the next closest" record. I hope this makes sense.

                 

                David

                • 5. Re: Scrolling to a specific record...

                  rd_hughes wrote:

                   

                  What I would like to be able to do is scroll to / go to "today's date", whilst continuing to show all records.

                   

                  And if there is no date just go to the next one?  Here is another approach:

                   

                   

                  Create a calculation (result is date, unstored) in your table and call it Today with:

                       Get ( CurrentDate )

                   

                  Create another table occurrence of your table and join them as:

                       Data::Today Data 2::yourDate

                   

                  Then it is a single script-step of:


                       Go To Related Record [ Data 2 ; using current layout ]


                  ... and do NOT check anything below (leave all unchecked).  The result is that it will jump to the current date (or one day later) no matter where your cursor starts in the record set, the found set, or how it is sorted.  With this, you do not lose your found set.

                  • 6. Re: Scrolling to a specific record...

                    OK, this definitely isn't elegant, but I think I have a solution (using both of your suggestions in some way, Mike and Debi):

                     

                         # Find closest date to today

                         Show All Records

                         Enter Find Mode []

                         Set Field [Table:DateField, "//..."]

                         Perform Find []

                         Sort Records (ascending)

                         Go to Record [Last]

                     

                         # Remember the closest date

                         Set Variable [$closest; Table:DateField]

                     

                         # Show all records and go to closest date

                         Show All Records

                         Sort Records (ascending)

                         Go to Record [First]

                         Loop

                              Exit Loop If [Table:DateField = $closest]

                              Go to Record [Next, Exit after last]

                         End Loop

                     

                    This seems to work...!

                     

                    Thanks again for all your help.

                     

                    David

                    • 7. Re: Scrolling to a specific record...

                      LaRetta,

                       

                      Thanks for this. I've found a solution via a script, I think -- see below -- but I can see that your solution would work as well.

                       

                      Thanks!

                       

                      David

                      • 8. Re: Scrolling to a specific record...

                        Sure. But really a multiple-find script which finds, loops, sorts ... when what I presented is a single step and none of that is required at all?  Speed diffrence alone will be huge.  You might want to take a look again. Would it help if you had a quick file? 

                        • 9. Re: Scrolling to a specific record...

                          Hmm... Is another table occurance a better / cleaner / simpler solution than a script? I accept that it's a messy script!

                           

                          I'm genuinely asking, btw. I'm a bit of a newbie at this!!

                           

                          Thanks again for your help.

                          • 10. Re: Scrolling to a specific record...

                            You are not adding another table but only an occurrence (representation of the table).  It is a cleaner solution when it:

                             

                            • Does not change your existing sort order + no sorting at all needed
                            • Does not change your existing found set + no finding at all needed
                            • Will be at least 5 times faster.
                            • Administering that script will be more difficult months down the road if you need to change something; not so with a single-step of GTRR
                            • Less chance that something can go wrong  ...

                             

                            Yes, it is far better in this case.  I use scripted finds all the time and I prefer them in many cases but this isn't one of them (sorry Debi and Mike, I think you know this as well and just didn't think of it in the moment). 

                             

                            Message was edited by: LaRetta

                            • 11. Re: Scrolling to a specific record...

                              Understood!

                               

                              I'll implement your solution now

                               

                              Thanks again!