A combo box allows the user to enter a text item or choose one from the combo box list.
The BeforeUserChanged and AfterUserChanged events run each time the user selects an item in the combo box list, or presses the up arrow or down arrow key to move to a different list item. All other VBA field events function normally for a focusable combo box field.
VBA uses string values for each item in a combo box. When you set the value of a combo box, VBA sets the value to the combo box field. If the value doesn’t exist in the item list, VBA won’t add it to the list. However, Microsoft Dynamics GP application code typically asks the user if they want to save a new item in the combo box field when the user dismisses the window.
The following event procedure checks the value of the Budget Year combo box field in the Budget Maintenance window, then enables or disables the Display radio group:
Private Sub BudgetYear_AfterUserChanged() 'Check the Budget Year combo box If BudgetYear = "2004" Then 'Disable the Display radio group Display.Enabled = False Else Display.Enabled = True End If End Sub