3 Replies Latest reply on Jul 5, 2011 8:49 AM by philmodjunk

    Script record printing preview help

    RobertGolden

      Title

      Script record printing preview help

      Post

      Hello

      I have a print preview issue when running from a script I could use a hand with

      The database was written in FileMaker Pro 10, Currently running FM 11.02 on a windows XP machine and remotely accessing the databse from my windows XP machine also running 11.02. I have some work done in Filemaker but am still a novice.

      The purpose of the button/script is to open 1 or 10 new records and print the form(s) for the production floor. I have a working copy “attached picture” but there are two issues I would like to solve that I have run aground on.

      1. When the script enters preview mode it always displays the first record in the table, I would like it to display the record that is to be printed.   Oddly enough, the current working script always prints out the newly created record UNLESS I start putting in Record Search or Quick Search script commands, then it displays and prints the first record in the table. I also included in the attachment one example of adding a quick search script command, that regardless of where I place it in the script within the loop, it always prints the first record in the table and not the newly created record. I am guessing there is a known step/procedure I am not aware of to solve this.


      2. I would also like the script, when 10 new records are requested, to print all 10 records at one time, so that the user only has to get the printer dialog box once. It may be that the recommendation for the first issue leads me down this path but I figured I would throw it out there if it influences the suggestion for issue #1

      Thanks & Best Regards
      Robert

      FM_Script.JPG

        • 1. Re: Script record printing preview help
          philmodjunk

          When Printing, there are two options you can specify: Records Being Browsed or Current Record. Records Being Browsed prints the entire found set of records so this should enable you to print all 10 records in one print job if they are all to be printed from the same layout. (Create your records in the loop, then use a single Print step after you exit the loop).

          Preview Mode always assumes the "records being browsed" option so you'll see the first record in your found set previewed insted of the current record. You can click the book control to page through the previewed report to get to the current record and you may be able to use Go To Record/Page/Request to advance the previewed report to the current record if you can determine which page will contain the current record. (Not always possible as you may have layouts that use sliding fields)

          IYou can also isolate the current record in a found set of one record and then your preview will show the current record that way as it is now the only record. In your case, that could easily be done if you performed a find for the new record instead of a quick find. (You can also set up a completely empty found set before creating new records and then your found set will only contain the new records your script contains.)

          Here's a way to produce an empty found set that works reliably in networked environments:

          Enter Find Mode[]
          Set Field [NCR Log::NCR Number ; -1] //I'm assuming no record will ever have -1 in this field
          Set Error Capture [on]
          Perform Find[]
          //now put your code here to create and print your new records.

          • 2. Re: Script record printing preview help
            RobertGolden

            1st Phil Thanks for the help

            I see what the plan is but it wasn't working. After some attempts I found that entering the find mode, setting the field to -1 or other value, then doing the perform find was sending the error "not a valid find request" and was not producing an empty found set but is reverting to all records shown. I next tried putting the -1 value in the ENTER FIND MODE command and removing the set field command and that seemed to work for both the single and the set of 10. Now that I think about it, the NCR Number field is set on record creation and cannot be modified by the user, so I guess that is why the set field didn't work.

            Thanks again!!!

             

            • 3. Re: Script record printing preview help
              philmodjunk

              Chances are you had the -1 in the wrong part of the set field step. The validation rules you've set for this field should not prevent set field from entering the criteria in this fashion. If it did, your Enter Find Mode alternative would have tripped the same error.

              Since the error message indicated that there wasn't any valid criteria entered, I would guess that your set field step looked like this:

              Set Field [NCR Log::NCR Number  [-1]]

              instead of like this:

              Set Field [NCR Log::NCR Number ; -1]