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

ID: Q184034


The information in this article applies to:
  • Microsoft Access versions 7.0, 97


SUMMARY

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

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, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals 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 needs. If you have limited programming experience, you may want to contact a Microsoft Certified Solution Provider or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Solution Providers, please see the following page on the World Wide Web:

http://www.microsoft.com/mcsp/
For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp
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.

  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:


  5. 
          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 
  6. Open the Orders form in Form view and double-click the Salesperson field to advance to the next record in the combo box.



REFERENCES

For more information about the ListIndex property, search the Help Index for "ListIndex," or ask the Microsoft Access 97 Office Assistant.

Additional query words: drop-down

Keywords : kbdta kbdtacode AccCon PgmEvnt PgmHowto
Version : WINDOWS:7.0,97
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: July 6, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.