Log In    |    Knowledge Base    |    4D Home
Tech Tip: Displaying the page number to the printout
Published On: April 27, 2001
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

Normally, when you print a form there is no page number included in the printout. However, the page number may be included in the printout by adding a counter variable to the form. This variable can be placed in either the Header or Footer area or in both. It must be set to accept the On Header and/or On Printing Footer events - depending on the location of your counter variable. Each time printing is performed, the counter should be incremented by 1 for each page printed.

The following is an example procedure that shows how to print the current page number in the Footer area.

1. Modify your print form as follow:

  • Open up the form in editing mode.
  • If the output area Markers are not turned on, turn them on by selecting Display Markers from the Forms Menu. You may also find it helpful to display Marker Labels.
  • Create a variable called "vPageCounter" under the footer line. You should adjust the settings in the Object Properties or Property Lists so that the variable will be displayed according to your preference.
  • Drag down the footer line so that it is right underneath the vPageCounter variable.
  • Make sure that the On Printing Footer is turned on for the vPageCounter variable.
  • Click Edit in the Property Lists to create an object method for vPageCounter:
    Object Method: vPageCounter
    If(Form event=On Printing Footer)
    End if

2. In the method that will call the Print command, initialize the variable "vPageCounter" to 0 before the print job is started.

For example:

Method: DoPrint
SET PRINT PREVIEW(True) ` remove this line if you don't want to preview the print job
SET PRINT PREVIEW(False) ` remove this line if you don't want to preview the print job