7 Replies Latest reply on Apr 14, 2013 10:26 PM by milkman

    Simple script problem



      Im trying to write a quick database for small business to reconcile their books and categorize expenses for tax purposes. I have all of the fields defined and am writing scripts to copy data from an AMOUNT field and post it to its corresponding expense field. I am not a Script wiz. Anybody got a min. to steer me in the right direction? Here is what i tried first...



      if[table::Category = "Sales"

      Copy [select; Table::Amount]

      Paste [select; Table::Sales]

      Go to record/request/page [Next]

      End If

      End Loop


      My problems with it are:

      It will only work if i select the first record that has the word Sales in it and then execute the script.

      It will stop after it gets to the last consecutive record that has the word sales in it. so if there is an item further down the page that is designated for sales, i would have to run it again.


      My goal:

      I have to categorize all of the items that small business needs for categories. I don't know if it can be written in one script to make it work or not.

      I have always written simpler databases for people that do not require a lot of scripting.

      Is there a simple way to make this work? I'd love to post it up for other small business people to use.

      It might save somebody time. maybe i could have the data automatically copy the data when the value list for Category is utilized....hmmmm


      I use it for my prep but thought if i didnt have to copy and paste into the field over to the right, i could save a ton of time. lol, lazyness is the mother of invention....

        • 1. Re: Simple script problem

          Your go to record step is in the wrong place.  Also don't use copy and paste.  Try:


          Go to record [first]



          Set field[table::Sales;table::Amount]

          End if

          Go to record/request/page [next;Exit after last]

          End loop

          • 2. Re: Simple script problem

            Yes, yes, yes yes,yes!  Wow that is so much simpler!  AND IT WORKS!


            That set field command is really nice.  I've never used that before either.


            Do you think after I make every script using this format that I can make a master script to execute them all at once?

            • 3. Re: Simple script problem

              You cam also eliminate the If and EndIf statements with the following Set Field:

              Set field[table::Sales; If(table::category="Sales";table::Amount;table::sales)


              There is no need to build separate scripts and then a master script to run the separate scripts.  Just build one script with all of the steps built into the one the one script.  If you use the Set Field example in this post, your script can be fairly short.

              • 4. Re: Simple script problem

                So, I'd set them up in tandem kinda like this?


                Go to Record/Request/Page [First]


                Set field[table::Sales; If(table::category="Sales";table::Amount;table::sales)

                Set field[table::Loan; If(table::category="Loan";table::Amount;table::Loan)

                Set field[table::Draw; If(table::category="Draw";table::Amount;table::draw)

                Set field[table::COG'S; If(table::category="COG'S";table::Amount;table::cogs)

                Go to Record/Request/Page [Last]

                End loop


                and just let it go?

                There has to be some formatting changes i think.  i could not get it to run correctly.

                • 5. Re: Simple script problem

                  Let her rip!

                  • 6. Re: Simple script problem

                    Should be Go to record/request/page [next;Exit after last]  not Go to Record/Request/Page [Last]

                    • 7. Re: Simple script problem

                      Yup!  That made it work.  It takes a little while, but it really gets everything pasted into the fields where it needs to go.  I should clean this up, make it easy to use, put some instructions in it and post it somewhere so if anybody wants it they could have it.


                      Thank you for helping me!