An integer field displays a number between -32,768 and 32,767.
All VBA events function for a focusable integer field.
VBA uses a string value when referencing an integer field. If the integer field includes a format (such as a percent field), VBA returns the formatted string value, including the decimal separator and percent sign (such as “3.15%”). To set the value of a formatted integer field, only include the decimal separator (“3.15”). The accounting system adds any other formatting characteristics.
In the following example, VBA code sets the Transaction Total integer field to 50 when the user enters a new batch in the Sales Batch Entry window:
Private Sub BatchID_AfterUserChanged() If Origin = 0 Then 'No batch origin specified. This is a new batch. TransactionTotal = "50" End If End Sub
This example sets an integer field (Percent) that’s formatted with two decimal places. It calculates a new commission percent based on commissioned sales:
Private Sub CommissionedSales_BeforeUserChanged(KeepFocus _ As Boolean, CancelLogic As Boolean) If CCur(CommissionedSales) + CCur(NonCommissionedSales) > _ 200000 Then Percent = "4.50" 'Set the percent to 4.50% Else Percent = "3.00" 'Set the percent to 3.00% End If End Sub