Microsoft KB Archive/209853

= ACC2000: How to Move to the Next Item in a Combo Box by Using a Double Click =

Article ID: 209853

Article Last Modified on 6/23/2005

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q209853



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

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



SUMMARY
This article shows you how to create a sample user-defined procedure that allows 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: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the 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 then double-click the Salesperson field (which is also a combo box) to advance to the next record in the combo box.

<div class="references_section">