AnsweredAssumed Answered

Printing Script Doesn't Work With More Than 1 Record

Question asked by senriz_1 on Nov 28, 2009
Latest reply on Dec 1, 2009 by philmodjunk

Title

Printing Script Doesn't Work With More Than 1 Record

Post

Hello... I'm a novice using FMP9 Adv.  I have a printing script that is pretty complex and works beautifully when there is only ONE record.  A little background so the script is understood... I have a layout that has 49 tabs and each tab is represent of a form.  The user selects which form to print in a set by a checkbox.  When these forms get printed they MUST be numbered Pg __ of __.  My print checkbox is called Print1, Print2, etc.  When there is more than one record created whether pertaining to the same student or another I get funky page numbering, like Pg 14 of 7.   And sometimes I get pages from another record that have been previously saved, while other times a particular selected form doesn't even print in the set.  When I remove all but one record... it works perfectly.  Below is my script, scaled down due to the multitude of forms.  Any help would be greatly appreciated.  Also, please note the second Print to PDF is an "append".  Thanks!!

 

Set Field [ Global::gTotalPages; IEP:: Print1 + IEP:: Print2 + IEP:: Print3 ]
Set Variable [ $fileName; Value:"file:" & Get(DesktopPath) & "GenerateForms" & ".pdf" ]
Set Field [ Global::gPageNumber; 0 ]
Go to Layout [ “IEP Forms” (IEP) ]
If [ ValueCount(IEP:: Print1) > 0 ]
Go to Layout [ “Form 1” (IEP) ]
Print Setup [ Orientation: Portrait; Paper size: 8.5" x 11" ]
[ Restore; No dialog ]
Enter Preview Mode
Go to Record/Request/Page  Last ]
Set Field [ Global::gPageNumber; Global::gPageNumber + Get ( PageNumber ) ]
If [ Global::gPageNumber = 1 ]
Save Records as PDF [ File Name: “$fileName”; Current record ]
[ Restore; No dialog ]
End If
End If
Go to Layout [ “IEP Forms” (IEP) ]
If [ ValueCount(IEP:: Print2) > 0 ]
Go to Layout [ “Form 2” (IEP) ]
Print Setup [ Orientation: Landscape; Paper size: 11" x 8.5" ]
[ Restore; No dialog ]
Enter Preview Mode
Go to Record/Request/Page  Last ]
Set Field [ Global::gPageNumber; Global::gPageNumber + Get ( PageNumber ) ]
If [ Global::gPageNumber = 1 ]
Save Records as PDF [ File Name: “$fileName”; Current record ]
[ Restore; No dialog ]
Else
Save Records as PDF [ File Name: “$fileName”; Current record ]
[ Restore; Append; No dialog ]
End If
End If
Go to Layout [ “IEP Forms” (IEP) ]
If [ ValueCount(IEP:: Print3) > 0 ]
Go to Layout [ “Form 3” (IEP) ]
Print Setup [ Orientation: Portrait; Paper size: 8.5" x 11" ]
[ Restore; No dialog ]
Enter Preview Mode
Go to Record/Request/Page
[ Last ]
Set Field [ Global::gPageNumber; Global::gPageNumber + Get ( PageNumber ) ]
If [ Global::gPageNumber = 1 ]
Save Records as PDF [ File Name: “$fileName”; Current record ]
[ Restore; No dialog ]
Else
Save Records as PDF [ File Name: “$fileName”; Current record ]
[ Restore; Append; No dialog ]
End If
End If

Enter Browse Mode
Go to Layout [ “IEP Forms” (IEP) ]

Outcomes