A push button performs actions, such as executing Microsoft Dynamics GP application code or VBA code.
The BeforeUserChanged and AfterUserChanged events occur when the user clicks a push button. The Changed event occurs when you set a push button using VBA. No other VBA field events occur for push button fields.
VBA uses numeric values when referencing push buttons. The value indicates the state of the push button. The “up,” or normal state of the button is 0; the “down,” or pushed state is 1. Setting the button’s value to 1 in effect “pushes” the button, and performs the same operation as if the user clicked the button.
You can change a text push button’s caption using the Caption property.
The following example displays a lookup window when the user moves to the Batch ID field and the field is empty. To display the lookup window, the procedure sets the lookup button field to 1:
Private Sub BatchID_AfterGotFocus() If BatchID.Empty = True Then 'The field is empty. Press the lookup button. LookupButton3 = 1 End If End Sub