Examples: AfterLostFocus event

In the following example, the AfterLostFocus event checks whether the Payment Terms field is empty. If it is, it displays a VBA dialog that asks the user if they want to enter one. If the user clicks Yes, the procedure opens the Payment Terms Lookup window:

Private Sub PaymentTerms_AfterLostFocus()
	Dim Response As Integer
	If PaymentTerms.Empty = True Then
		'Set a default payment term
		Response = MsgBox("Do you want to enter a payment term?", _
		If Response = vbYes Then
			'Click the payment term lookup button
			LookupButtons = 1
		End If
	End If
End Sub

Documentation Feedback