4 Replies Latest reply on Apr 25, 2012 4:45 PM by KBGF75

    set date range using drop-down calendar

    KBGF75

      Title

      set date range using drop-down calendar

      Post

      In my FMP9 file the Donations table includes a record for each donation. I use a script to find a set of donation records within a range of dates. I have been specifying the date range in a single global text field, Date_range_for_find, using the format mm/dd/yy..mm/dd/yy.

       The two dates are now entered manually into the Date_range_for_find field.  Instead of manual entry, I want to use a drop-down calendar to specify each date. I expect to use the calendar to set two global date fields, initial_search_date and final_search_date.

       How should I modify the existing script, which is:

                      Go to Layout [“Donation Reports”(Donations)]

                      Enter Find Mode []

                      Go to Field [Donations::Date of Donation]

                      Set Field [Donations::Date_range_for_find]

                      Perform Find []

                      Exit Script []

        • 1. Re: set date range using drop-down calendar
          philmodjunk

          Go to Layout [“Donation Reports”(Donations)]

                          Enter Find Mode []

                          Go to Field [Donations::Date of Donation]

                          Set Field [Donations::Date_range_for_find ; Donations::initial_Search_date & "..." & Donations::final_search_Date ]

                          Set Error capture [on]

                          Perform Find []

                          Exit Script []

          The lines I crossed out can be removed from your script as they do not have any effect on how your script runs.

          Set Error Capture [on] keeps the "no records found" dialog from interrupting your script if no records are found or no criteria is entered. You can use get ( lastError ) or get (foundcount) in an if step immediately after the Perfrom Find step if you want to check for no records found and display your own, more user friendly message in place of the built in message set error capture suppresses.

          • 2. Re: set date range using drop-down calendar
            KBGF75

            Here is the complete script I want to run. It's based on your advice, but I've made a few changes to layout and field names. It runs, and the Insert Text command works. But, the found set of records doesn't change. If I run the script with Set Error Capture [Off] I get this error message: "There are no valid criteria in this request. Type a valid request before clicking Find."

            DonDateField1 and DonDateField2 are global fields in date format. If I enter dates manually into those two fields (vice using drop-down calendar) and then run the script, the result does not change. If I perform a Find directly (no script), having entered the date range manually into the Date of donation field, the expected found set does come up.

            Where am I going wrong?

               Go to Layout [“Donation Reports Copy” (Donations)]

               Enter Find Mode []

               Set Field [Donations::Date of donation[Donations::DonDateField1&”…”&Donations::DonDateField2]]

               Set Error Capture [On]

               Perform Find []

               Insert Text [Select; Donations::Donations_found_set_description; “All donations”]

            • 3. Re: set date range using drop-down calendar
              philmodjunk

              See the extra brackets in your set field that are not in mine. This indicates that you entered Donations::DonDateField1&”…”&Donations::DonDateField2 in the wrong place.

              When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.

              And I'd use Set field in place of Insert text here.

              • 4. Re: set date range using drop-down calendar
                KBGF75

                 Ah, so! Lesson learned. Thanks.

                     -Al