Examples: PullFocus method


The following procedure runs when the user clicks a button in a VBA user form. It saves the contents of the Receivables Transaction Entry window by programmatically “clicking” the Save button. In this case, the save occurs even though the user entered a non-existent shipping method in the currently focused field in the window (Shipping Method). No warning dialog appeared, and the partial shipping method wasn’t saved:

Private Sub CommandButton1_Click()
	ReceivablesTransactionEntry.Save = 1
	ReceivablesTransactionEntry.Close
End Sub

Using the PullFocus method, the same example can conditionally save the contents of the window only if data in the focused field is valid. In this case, when the PullFocus method moves the focus out of the Receivables Transaction Entry window, the Microsoft Dynamics GP user changed and lost focus events verify the currently-focused field (Shipping Method). If the field contains invalid data, the PullFocus method returns False, and the save isn’t performed:

Private Sub CommandButton1_Click()
	If ReceivablesTransactionEntry.PullFocus = True Then
		ReceivablesTransactionEntry.Save = 1
		ReceivablesTransactionEntry.Close
	End If
End Sub


Documentation Feedback