2 Replies Latest reply on Aug 6, 2013 7:32 PM by LynnRogers

    Date Scripts



      Date Scripts


           I have worked on this and I can not figure it out. Need help please. I am using FM Pro 12 Advance and I need a script that can find dates in multiple fields. I have a table named Work Order and it has 6 date fields. 5 of them represent up to 5 different times I have worked on a peace of equipment and they are on the layout named Date 1, Date 2, Date 3, Date 4, & Date 5. The sixth date field is not on the layout and is named Select Date. I need a script that when I put a date into the Select date field it will search all 5 date fields (Date 1, Date 2, Date 3.....looking for all matching dates.

        • 1. Re: Date Scripts

               This sounds like a case where you need a table of related records with one related record for each of your 5 date fields. This would make the find script simpler as well as providing a more flexible way to handle this data.

               Using the existing structure, you could write a script like this, provided that global storage is specified for your select date field:

               Enter Find Mode []
               Set field [YourTable::Date1 ; YourTable::SelectDate ]
               New Record / Request
               Set Field [YourTable:: Date2 ; YourTable::SelectDate ]
               #And so forth--creating a new "request" for each criterion so that you find records with the date in date1, date2... OR Date 5
               Set Error Capture [on]
               Perform Find[]

               You may find this thread of scripted find examples helpful:  Scripted Find Examples

               If you don't specify global storage for select date, you'd need to set a variable to the value of select date before entering find mode and then the set field steps would need to refer to the variable instead of select date.

               Note that with a related table, this script becomes:

               Enter FInd Mode []
               Set Field [RelatedTable::Date ; YourTable::SelectDate ]
               Set Error Capture [on]
               Perform FInd[]

          • 2. Re: Date Scripts

                 Thanks for the help Phil it works like a charm.