Examples: BeforeClose event


In the following example, the BeforeClose event procedure for the Invoice Entry window checks whether the user entered a comment ID. If not, it displays a message dialog using VBA’s MsgBox() function. If the user clicks Yes, the procedure cancels the close using the AbortClose parameter, and the user can enter a comment ID:

Private Sub Window_BeforeClose(AbortClose As Boolean)
	Dim Response As Integer
	If CommentID.Empty = True Then
		Response = MsgBox("Do you want to enter a Comment?", vbYesNo)
		If Response = vbYes Then
			AbortClose = True
			CommentID.Focus
		End If
	End If
End Sub


Documentation Feedback