The following example sets the Sort By list field in the Customer Maintenance window when the window opens:
Private Sub Window_AfterOpen() 'Set the Sort By list to "By Salesperson ID" SortBy.Value = 5 End Sub
The following example sets the value of the Batch ID string field when the user chooses a document type from the Document Type drop-down list:
Private Sub DocumentType_AfterUserChanged() Select Case DocumentType 'Set the batch ID to one of three existing batches Case 1 BatchID.Value = "DAILYSLS" Case 7 BatchID.Value = "DAILYRET" Case Else BatchID.Value = "DAILYMISC" End Select End Sub
The following example checks the value of the Checkbook ID field, then sets the value of the Cash Account composite field to an existing account number. Note that the syntax omits the Value property:
Private Sub CheckbookID_Changed() If CheckbookID="FIRST NATIONAL" And CashAccount.Enabled=True Then CashAccount = "100-5100-00" CashAccount.Enabled = False ElseIf CheckbookID <> "FIRST NATIONAL" Then CashAccount.Enabled = True End If End Sub