I've been trying to write a script that basically would say If Print1
= 1, then go to layout Form 1 and save as PDF and then, go to Print2
and if Print2 = 1, go to layout Form 2 and append to PDF, and so
on... BUT if Print1 = 0, then go to Print2 and if Print2 = 1, go to
layout Form 2 and save as PDF or if Print2 = 0, then go to Print3.
And so on, and so on. THIS IS NOT WORKING FOR ME!!!
I need this script to go through all the forms to see if the field is
checked and if it is, then all those that are checked need to print to
the PDF, with the "Page __ of __."
Can anyone help me?
I'm not sure that you can appened to an existing PDF, but assuming newer
versions of FileMaker allow this, then the "printing" Script itself is
fairly easy ... you've already given the basic version above. All you need
is a set of separate If / End If statements.
i.e.
If Print1 = 1
Go To Layout [Form1]
Page Setup [Restore; NoDialog]
Print []
End If
If Print2 = 1
Go To Layout [Form2]
Page Setup [Restore; NoDialog]
Print []
End If
If Print3 = 1
Go To Layout [Form3]
Page Setup [Restore; NoDialog]
Print []
End If
{continue for all Forms required}
The bigger problem is the "Page X of Y". his is going to be impossible to do
thanks to FileMaker's Preview mode not being 100% accurate to what gets
printed / PDFed ... unless each Form is always a single page, then it is
possible using a "Counter" global field / variable.
Helpfull Harry :o)
Thanks!! I'll try that and let you know how it goes.
Helpfull Harry :o)
Thanks. I will keep that in mind. I haven't gotten to the
"landscape" forms yet... just working on the first few which are all
portrait. I'm using FMP 9 Advance. Below is my script so far and
it's working perfectly. Your instructions were very helpful... I had
a nested if statement that was causing the problem. Can you advise me
on how I might add a TotalPageCount... like Page __ of "__"?
Go to Layout [ “IEPForms” (IEP) ]
Enter Preview Mode
Set Field [ Global::gPageNumber; 0 ]
Go to Layout [ “IEPForms” (IEP) ]
If [ ValueCount(IEP::Print1) > 0 ]
Go to Layout [ “Form 1” (IEP) ]
Enter Preview Mode
Go to Record/Request/Page [ Last ]
Set Field [ Global::gPageNumber; Global::gPageNumber + Get
(PageNumber) ]
Print [ Restore; No dialog ]
Go to Layout [ “IEPForms” (IEP) ]
End If
If [ ValueCount(IEP::Print2) > 0 ]
Go to Layout [ “Form 2” (IEP) ]
Enter Preview Mode
Go to Record/Request/Page [ Last ]
Set Field [ Global::gPageNumber; Global::gPageNumber + Get
(PageNumber) ]
Print [ Restore; No dialog ]
Go to Layout [ “IEPForms” (IEP) ]
End If
Enter Browse Mode
There are three possibilities ...
VARIABLE LENGTH FORMS
If the number of pages for any Form can vary depending on the data (i.e.
Form 4 might sometimes be 2 pages, sometimes 3 pages), then it�s simply not
possible to know the total number of pages that will be printed due to
FileMaker�s inaccurate Preview Mode ... that means your Preview / Go To Last
Page Script won't always give the correct answer. :o(
SINGLE PAGE FORMS
If ALL the Forms are only one page long, then it�s very easy.
First you can calculate the total number of pages for the entire report by
simply adding up all the checkbox values (since they are either 1 or 0). It�
s probably easiest to calculate this value at the start of the Script and
store it in a Global Field or Variable.
The �current� page number for each Form can be set using a second Global
Field / Variable as the Script runs through, remembering to reset it to 0 at
the start of the Script.
Both Fields / Variables can be put in the Footer of each Layout. It�s
probably easiest to use Merge Fields.
e.g.
Page <<g_Current>> of <<g_Total>>
This means your printing / PDFing Script would be something like:
Set Field [g_Current; 0]
Set Field [g_Total; Form1 + Form2 + Form3 + ...]
If Form1 = 1
Set Field [g_Current; g_Current + 1]
Go To Layout [Layout1]
Page Setup [Restore; No Dialog]
Print []
End If
If Form2 = 1
Set Field [g_Current; g_Current + 1]
Go To Layout [Layout2]
Page Setup [Restore; No Dialog]
Print []
End If
If Form3 = 1
Set Field [g_Current; g_Current + 1]
Go To Layout [Layout3]
Page Setup [Restore; No Dialog]
Print []
End If
... {continue for all necessary Forms}
MULTI-PAGE FORMS
If some / all of the Forms are multiple pages (but each is always the same
number), then it might be easier to not bother trying to number the pages,
but instead use the above method to number the Forms rather than pages in
the Footers.
i.e.
Form <<g_Current>> of <<g_Total>>
Trying to actually number the pages will get a bit messy � the easiest
approach is probably to split each Form�s pages into separate Layouts, and
then use the same method above. So if Form 2 is three pages long, then it
would become three separate Layouts and that section of your Script would
become:
If Form2 = 1
Set Field [g_Current; g_Current + 1]
Go To Layout [Layout2_Page1]
Page Setup [Restore; No Dialog]
Print []
Set Field [g_Current; g_Current + 1]
Go To Layout [Layout2_Page2]
Page Setup [Restore; No Dialog]
Print []
Set Field [g_Current; g_Current + 1]
Go To Layout [Layout2_Page3]
Page Setup [Restore; No Dialog]
Print []
End If
You would also need to modify the total pages calculation to multiply the
appropriate checkbox value by the number of pages for that Form.
e.g.
If ALL Forms have two pages, the calculation is:
Set Field [g_Total; Form1 * 2 + Form2 * 2 + Form3 * 2 + ...]
or more simply:
Set Field [g_Total; (Form1 + Form2 + Form3 + ...) * 2]
If the Forms have differing numbers of pages, the calculation is:
Set Field [g_Total; Form1 + Form2 * 3 + Form3 * 4 + ...]
when Form 1 has one page, Form 2 has three pages, and Form3 have 4
pages.
Helpful Harry :o)
Thank you so very much!! I got it to work beautifully. I actually
had put each page on a layout all by itself when a form had multiple
pages, so that ended up being a bit easier. Also, I got the Landscape
and Portrait print to work quite well. I add the Print Setup Function
above the Print Function enabling either Portrait or Landscape when a
Form's orientation changed. So if the first Five Forms were Portrait
I only needed to put that Function in the first one, then change it
for Form 6 to Landscape, and then only change it again when one of the
following Forms changed back to Portrait. Again, thank you. Your
instructions were extremely helpful.
Not quite. You'll need to put the Page Setup command in EVERY Form's "If /
EndIf" section - otherwise if they don't choose to print Form 1 the Page
Setup could be set incorrectly (e.g. a left-over from printing just Form 6
previously) whrn printing Forms 2, 3, 4 or 5.
Helpfull Harry :o)
Sure enough. That is what happened. Thank you.