Examples: Parent property

In the following example, two procedures illustrate how to use the Parent property. The first procedure uses the Call statement to call a sub procedure named FieldCaption after a Microsoft Dynamics GP window opens. It passes the window’s Customer ID field as an object to the procedure.

The second procedure is a new sub procedure defined for the module. It receives the Customer ID field object passed from the first procedure. The procedure then uses the Parent property to ascertain the name of the window where the field was passed from, and changes the field’s caption based on the window’s name:

Private Sub Window_AfterOpen()
	'Pass a window field to the FieldCaption procedure 
	Call FieldCaption(CustomerID)
End Sub
Public Sub FieldCaption(FieldObj As Object)
	If FieldObj.Parent.Name = "CustomerMaintenance" Then
		CustomerMaintenance.CustomerID.Caption = "Customer No."
	ElseIf FieldObj.Parent.Name = "InvoiceEntry" Then
		InvoiceEntry.CustomerID.Caption = "Cus. No."
	End If
End Sub

Documentation Feedback