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 Retrieve Selected Values from a Multiple Selection List Box in a Data Access Page


View products that this article applies to.

This article was previously published under Q225098
Advanced: Requires expert coding, interoperability, and multiuser skills.

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

↑ Back to the top


Summary

This article shows you how to retrieve the items that you select from a multiple selection list box in a data access page.

↑ Back to the top


More information

For an example of how to retrieve the values that you select in a multiple selection list box, follow these steps:
  1. Open any Access 2000 database.
  2. In the Database window, click Pages under Objects, and then click New.
  3. In the New Data Access Page dialog box, click Design View, and then click OK.
  4. Add a list box to the page, and then set the following properties:
       Id: CList
       ListRowSource: Table: Customers
       ListBoundField: CompanyName
       Multiple: TRUE
    					
  5. Add a command button to the page, and then set the following properties:
       Id: cmdList
       InnerText: List Values
    					
  6. On the Tools menu, point to Macro, and then click Microsoft Script Editor.
  7. On the View menu, point to Other Windows, and then click Script Outline.
  8. Expand the cmdList node, and then double-click onclick.
  9. Type or paste the following script:
    <SCRIPT event=onclick for=cmdList language=vbscript>
    <!--
    
     'Check CList for selected Items - Use a message box to display
      
      dim x
      dim values 
      
      Values = "The selected values are: " & vbcrlf
     
      for x = 0 to CList.length - 1 
         if CList.item(x).selected then
            values = values & CList.item(x).value & vbcrlf
         end if
      next
      msgbox values
    
    -->
    </SCRIPT>
    					
  10. On the View menu, click View in Browser.
  11. Select multiple items from the list.
  12. Click the command button. Note that a message box appears. The message box lists the items that you selected.

↑ Back to the top


Keywords: KB225098, kbhowto

↑ Back to the top

Article Info
Article ID : 225098
Revision : 2
Created on : 6/24/2004
Published on : 6/24/2004
Exists online : False
Views : 316