4 Replies Latest reply on Sep 2, 2013 8:32 AM by philmodjunk

    Printing Scripts???

    SamuelWinkler

      Title

      Printing Scripts???

      Post

           I have a user form that I want to be the only form that the end user needs to access.... Lets call this form USERFORM... From this form I have established portals to allow the end user to add data to other tables that are related... I have made reports that I want the end user to be able to print... How do I script a button that will do the following 

           1. Select report 1 

           2. Print report 1 for current record only

           3. Select report 2

           4. Print report 2 for current record only

           5. Select report 3

           6. Print report 3 for current record only

           and then remain or end on the USERFORM.  Ideally I want this to be automated so the end user does not have to select the reports that are needed but that they will print automatically.

            

            

            

            

        • 1. Re: Printing Scripts???
          SteveMartino

               I think simply, put a button on USERFORM that does all 6 steps and returns to USERFORM.

               First you  have to establish the context of the reports.  When you go to the report (1, 2, 3) does it already have the proper records, or does opening the report trigger the proper find/sort?  If it does, then a script like this should be a basic start:

               Show Custom Dialog [Print Reports?]

               If [Get (LastMessageChoice) = 2]

                   Exit Script []

               Allow User Abort [off]

               End If

               Go to Layout ["Report 1" (proper layout here)

               Print Setup [Restore; No dialog}  //Select your printer here

               Print [Restore: Printer Name Here]  //Specify under print options "current record only"

          Now if going to the next report will already have the proper records, you could continue:

               Go to Layout ["Report 2" (proper layout here)

               Print Setup [Restore; No dialog}  //Select your printer here

               Print [Restore: Printer Name Here]  //Specify under print options "current record only"

               Go to Layout ["Report 3" (proper layout here)

               Print Setup [Restore; No dialog}  //Select your printer here

               Print [Restore: Printer Name Here]  //Specify under print options "current record only"

               Go to Layout [original layout}

                

          • 2. Re: Printing Scripts???
            SamuelWinkler

                 That seems to make some sense... I am still very new to this but trying to jump in head first it is sort of a sink or swim endevouer with this is a what I want to do now lets figure out how to make it happen approach. :D

                 if i wanted it to print usings the default printer what would i type or will it auto change based on location DB is deployed?  

                 also I tried the script as you suggested but nothing printed... any suggestions

                  

            • 3. Re: Printing Scripts???
              SteveMartino

                   Do you have FM Advanced?  You could use Script Debugger & Data Viewer to step thru the script and see what it's doing or not doing. It's hard to give further advice without not knowing more about your database. 

                   Regarding printing, is the database used on a server, at least multi-user environment?  If so in the script you could assign a printer in the script based on the user.

              • 4. Re: Printing Scripts???
                philmodjunk

                     If you want the printing to be totally automated and will print from different installations with different printers, you may want to use a plugin such as the MyFMButler plug in to get more precise control of the printing process.

                     Sometimes I do an end run around that complication by not fully automating the print. I'll have the script enter preview mode and pause. The user then selects print from the File menu. That's a pretty familiar options for must users as that's how you'd print from almost any application. The main draw back to that is you may have to educate your users on the difference between Records being browsed and Current record. (If your report is based on just one record, however, you can create a found set of just that record and then either option produces the same result.)

                     You mentioned the use of portals for displaying your data on this layout. In some situations that can cause complications for your printing process as you may not be able to display all rows of data unless you size the portal very large and set it to slide up. In other cases, it's much simpler and more flexible to set up your report layout by basing it on the portal's table with a scripted find or go to related records to pull up the correct records in a found set.