4 Replies Latest reply on Jan 17, 2011 10:22 AM by philmodjunk

    Help in writing a script

    EmmaSmith

      Title

      Help in writing a script

      Post

      I some help in writing a script. What I have is 4 fields with dates.  I need to do a find in all the fields for the month.  How do I write the script so it will give me all the records with the information I need in all 4 fields?

      Thanks!

        • 1. Re: Help in writing a script
          Rajkumar
          So set a variable in your script, with any variable name and put this function as this variables value.
          • 2. Re: Help in writing a script
            philmodjunk

            If your system uses MMDDYYYY date format (What we use here in the US.),

            Enter find mode
            Enter 1/2011 in a date field
            Perform the find and you'll find all records with a january, 2011 date in that field.

            Since you have 4 different fields--perhaps not the best structure for your data and you want a script....

            Define a global date field (a field of type date with global storage enabled in field options), called gDate

            use this script:

            Enter Find Mode[]
            Set Field [YourTable::DateField1 ; Month ( YourTable::gDate1) & "/" & Year ( YourTable::gDate1 ) ]
            New Record/Request
            Set Field [YourTable::DateField2 ; Month ( YourTable::gDate1) & "/" & Year ( YourTable::gDate1 ) ]
            New Record/Request
            Set Field [YourTable::DateField3 ; Month ( YourTable::gDate1) & "/" & Year ( YourTable::gDate1 ) ]
            New Record/Request
            Set Field [YourTable::DateField4 ; Month ( YourTable::gDate1) & "/" & Year ( YourTable::gDate1 ) ]
            Set Error Capture [on]
            Perform Find []

            Use your table and field names in place of mine in this script. When you enter a date in gDate1, this script will find all records with the same monthand year in at least one of the four date fields.

            If you do not use MMDDYYYY date format, there's a slightly different version you can use that enters a date range from first of the month to last of the month that can be used in each of the above set Field steps.

            • 3. Re: Help in writing a script
              EmmaSmith

              Thanks for your response but I am having trouble putting the set field in my script.  I tried to specify by calculation and it is not working.  If I type it the way you have it it tells me it needs a field name where Set field is. If I leave out the set field then it says I need an operator.  I am really sorry but I have little knowledge in writing scripts.  So how do I get the set field script in? I did change the table and field names and typed it exactly like you did but I am not sure if I am going about it the right way.

              Thanks!

              • 4. Re: Help in writing a script
                philmodjunk

                Set Field has two specify buttons and you must use both buttons to set it up correctly.

                Click the upper button to select the field to thw left of the semi-colon. Click the lower button and enter the text to the right of the semi colon. Instead of typing in table and field names, select them from the list of fields in the top of the specify calculation dialog by double clicking them so that you can be sure you have not accidentally mistyped the names.