Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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.

↑ Back to the top


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.

↑ Back to the top


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.

↑ Back to the top


Keywords: KB209853, kbdtacode, kbhowto

↑ Back to the top

Article Info
Article ID : 209853
Revision : 3
Created on : 6/23/2005
Published on : 6/23/2005
Exists online : False
Views : 345