Sample VB script code: assign fields from Page 1 to Page 2 etc - Support

Sample VB script code: assign fields from Page 1 to Page 2 etc

From Support

Jump to: navigation, search
Private Sub Form_BeforePrint (Device As fdPrintDevice, Cancel As Boolean)

'/////////////////////////////////////////////////////////////////////////////
' This script will simply assign the fields from Page one to the second
' (and third) page
'/////////////////////////////////////////////////////////////////////////////

	Dim lcField As Field		'Declare field object work variable
	Dim lcPage As Page		'Declare page object work variable
	

	'transfer values from page one to any corresponding values in the new page
	For Each lcField In Thisform.Pages( "PAGE_NAME_FOR_PG_1" ).Fields
	
		'/////////////////////////////////////////////////////////////////////
		'there is a chance that a field on page 1 is not in the new desired page.  This will cause an
		'error to occur when the value is copied.  We want to ignore this error and continue with the
		'other fields.  If this error-handling statement is not included, then this page will not print
		'out if an error occurs.
		'/////////////////////////////////////////////////////////////////////
		On Error Resume Next			'ignore errors
	
		ThisForm.Pages("PAGE_NAME_FOR_PG_2").Fields("FIELDNAME" + "2").Activate		'activate field
		ThisForm.Pages("PAGE_NAME_FOR_PG_2").Fields("FIELDNAME" + "2").Value = lcField.Value	'copy value

		ThisForm.Pages("PAGE_NAME_FOR_PG_3").Fields("FIELDNAME" + "3").Activate		'activate field
		ThisForm.Pages("PAGE_NAME_FOR_PG_3").Fields("FIELDNAME" + "3").Value = lcField.Value	'copy value
	Next

End Sub
Personal tools