Monday, March 25, 2013

Dynamics GP - Form Customization with VBA - Set Required Fields

This is a sample of script used to set multiple fields as required, and also open specific windows that require data.



Private Sub CustomerPONumber_AfterLostFocus()
If CustomerPONumber.Empty = False Then
UserDefined = 1
End If
End Sub

Private Sub CustomerID_AfterLostFocus()
If CustomerID.Empty = False And CustomerName.Enabled = True Then
ExpansionButton4.Value = 1
End If
End Sub


Private Sub CustomerPONumber_BeforeLostFocus(KeepFocus As Boolean, CancelLogic As Boolean)
If CustomerPONumber.Empty = True Then
MsgBox "Please Enter a Customer PO Number"
CustomerPONumber.Focus
End If
End Sub

Private Sub ShipToAddress_BeforeLostFocus(KeepFocus As Boolean, CancelLogic As Boolean)
If ShipToAddress.Empty = True Then
MsgBox "Please Enter a Ship To Address"
ShipToAddress.Focus
End If
End Sub

Private Sub Window_AfterOpen()
ShipToAddress.Required = True
CustomerPONumber.Required = True
End Sub


No comments:

Post a Comment