KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Adding page numbers to a printed form
PRODUCT: 4D | VERSION: 2004 | PLATFORM: Mac & Win
Published On: July 17, 2008
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

To add page numbers to the printed output of an existing form (in either the header or footer area), take advantage of the "Printing page" command and the "On Header" or "On Printing Footer" event.

First, to gain access to the header or footer areas, turn on the markers in the form. Right- or cmd-click (Mac OS X) the form to get the context menu, and select both "Markers" and "Marker Labels" to turn them on.



Then use the markers to create a space on the printed page for the page number. Grab the desired marker (header or footer) by its label, and drag it to leave enough space to place a variable. Now create a variable of type Alpha in the header or footer area.




Next make sure the variable object method triggers during the "On Header" or "On Printing Footer" event. Right- or cmd-click (Mac OS X) on the variable to open the Property List, and under the Events theme, select either "On Header" or "On Printing Footer", depending on whether you want to print page numbers in the header or the footer.




Finally, write the simple code that will execute when the event fires. Right- or cmd-click (Mac OS X) the variable and select the Object Method. To print "Page 1", "Page 2", etc., use the code:

vPageNum := "Page " + String(Printing page)




Now the printed output will have page numbering:



Commented by Bruce Bridges on October 9, 2009 at 12:32 PM
In migrating a database from 2003 to 2004, all forms that use the above page numbering approach generate compiler errors "Cannot make an assignment with those types". when doing a check syntax.