2 Replies Latest reply on Sep 13, 2010 4:20 AM by ARCMeg

    FormCalc date question

    ARCMeg

      I'm working on a timesheet. I browsed through some questions and answers on this forum and found what I needed to auto populate the dates for each day in a two week period given an intial entered date by the user. It works great but . . . There is a header at the top of the form which directs the user to pick the first date in the bi-weekly pay period. The table for the timesheet data is further down in the form. I would like them to be able to pick the date at the top and the first date in the timesheet table would auto populate - followed by all the other dates for the bi-weekly period. To accomplish this I created a "calculation" event for the first date in the timesheet table so that I could reference the date entered at the top of the form. That works great. Then all the scripting to auto populate the rest of the dates is set up as an "exit" event.

       

      Here's the problem I am trying to fix. The date is completed at the top . . . the first date in the timesheet table fills in, but the other dates do not auto populate at that time. The user would need to click in the cell in the timesheet table with the first date and click out to prompt the "exit" script to run and fill in the other dates.

       

      I'm trying to figure out a way that it would all happen seamlessly once the date at the top of the form is completed.

       

      Any help would be greatly appreciated!

        • 1. Re: FormCalc date question
          gkaiseril MVP & Adobe Community Professional

          Why not do all the calculations in the exit event of the field at the top for picking the date?

           

          You have all the data you need and it will only run when the field is exited and not every time a calculated field's data is entered.

          • 2. Re: FormCalc date question
            ARCMeg Level 1

            Thanks so much for your reply. I should have included that I tried doing what you are suggesting. Do the calculations in the exit event of the field at the top for picking the date. I couldn't get it to work. I'm pretty sure it is a reference problem.

             

            Following is the header line from the exit event for the date at the top:

             

            form1.Subform.Header.FromDate::exit - (FormCalc, client)

             

            Then the exit event header for the first date in the table:

             

            form1.Subform.Body.Table_.Row_[0].date::exit - (FormCalc, client)

             

            This is the script included with the exit event for the first date in the table

             

            var dayNum=Date2Num($.formattedValue,"MM/DD/YYYY")

            Row_[1].date.rawValue = Num2Date(dayNum+1,"MM/DD/YYYY")

            Row_[2].date.rawValue = Num2Date(dayNum+2,"MM/DD/YYYY")

            Row_[3].date.rawValue = Num2Date(dayNum+3,"MM/DD/YYYY")

            Row_[4].date.rawValue = Num2Date(dayNum+4,"MM/DD/YYYY")

            Row_[5].date.rawValue = Num2Date(dayNum+5,"MM/DD/YYYY")

            Row_[6].date.rawValue = Num2Date(dayNum+6,"MM/DD/YYYY")

            Row_[7].date.rawValue = Num2Date(dayNum+7,"MM/DD/YYYY")

            Row_[8].date.rawValue = Num2Date(dayNum+8,"MM/DD/YYYY")

            Row_[9].date.rawValue = Num2Date(dayNum+9,"MM/DD/YYYY")

            Row_[10].date.rawValue = Num2Date(dayNum+10,"MM/DD/YYYY")

            Row_[11].date.rawValue = Num2Date(dayNum+11,"MM/DD/YYYY")

            Row_[12].date.rawValue = Num2Date(dayNum+12,"MM/DD/YYYY")

            Row_[13].date.rawValue = Num2Date(dayNum+13,"MM/DD/YYYY")

             

            When I tried moving the script to the exit event header for the date at the top - it doesn't recognize the table properly.

             

            You can probably tell from my question that I am a beginner with this scripting and software.

             

            Any suggestions on how to combine the script at the bottom with the exit event header at the top so they recognize each other??

             

            Thanks again for your help.

             

            Meg