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



The information in this article applies to:

  • Microsoft Access 2000

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.

  1. Start Microsoft Access and open the sample database Northwind.mdb.
  2. Open the Orders form in Design view.
  3. Right-click the Salesperson combo box, and then click Properties.
  4. 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
    
    					
  5. 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.

REFERENCES

For more information about the ListIndex property, click Microsoft Access Help on the Help menu, type listindex property in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Modification Type:MajorLast Reviewed:6/23/2005
Keywords:kbdtacode kbhowto KB209853