Microsoft KB Archive/184034

= ACC: How to Move to the Next Item in a Combo Box with DblClick =

Article ID: 184034

Article Last Modified on 1/22/2007

-

APPLIES TO


 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q184034



Advanced: Requires expert coding, interoperability, and multiuser skills.



SUMMARY
This article shows you how to create a sample user-defined procedure that enables you to cycle through the records in a combo box by using a double-click.



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. The following example demonstrates how to use the OnDblClick property and the ListIndex property of a combo box to cycle through the records in that combo box by double-clicking it.

CAUTION: Following the steps in this example will modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file, or perform these steps on a copy of the Northwind.mdb database.

 Start Microsoft Access and open the sample database Northwind.mdb. Open the Orders form in Design view. Right-click the Salesperson combo box and then click Properties.  Set the OnDblClick property of the Salesperson combo box to the following event procedure: Private Sub EmployeeID_DblClick(Cancel As Integer) On Error GoTo Error_Handler Me![EmployeeID].ListIndex = Me![EmployeeID].ListIndex + 1 Exit Sub

Error_Handler: If Err.Number = 7777 Then ' End of the list - Move to the start. Me![EmployeeID].ListIndex = 0 Exit Sub Else MsgBox Err.Description, vbOKOnly, "Error #" & _ Err.Number & " occurred" End If     End Sub  Open the Orders form in Form view and double-click the Salesperson field to advance to the next record in the combo box.

<div class="references_section">