The following AfterActivate event procedure runs when the Customers And Prospects lookup window is activated. As the user browses through records in the Customer Maintenance window, the lookup window remains open, but deactivated. When the user activates the lookup window, this procedure places the focus on the same record in the lookup window as was displayed in the Customer Maintenance window:
Private Sub Window_BeforeActivate() 'Set the lookup sort list to item 2, "by Name" CustomerSortBy = 2 'Open the find dialog and make it invisible FindDialog.Open Dynamics.FindDialog.Visible = False 'Set the sort by list and locate the customer record displayed in 'the Customer Maintenance window FindDialog.CustomerSortBy = 2 FindDialog.SearchText = CustomerMaintenance.Name1 'Press the find button FindDialog.Find = 1 End Sub