ACC2000: How to Retrieve Selected Values from a Multiple Selection List Box in a Data Access Page (225098)



The information in this article applies to:

  • Microsoft Access 2000

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).

SUMMARY

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

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.

Modification Type:MajorLast Reviewed:6/24/2004
Keywords:kbhowto KB225098