How to Print a Report Based On Selections in a List

Last reviewed: February 23, 1996
Article ID: Q147310
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, versions 3.0 and 3.0b

SUMMARY

This article shows by example how to present the user with a form containing a multiple select list from a field in a table, and then print a report that contains only the selected records.

MORE INFORMATION

Step-by-Step Example

This example uses the Customer table from Testdata.dbc database in the \Samples\Data subdirectory.

  1. Create a new report. Add the Customer table to the Data Environment, and choose Quick Report from the Report Menu. Accept the defaults for a Quick Report. Save the report as CustRepo.

  2. Create a new form, and add the Customer table to the Data Environment.

  3. Add a List to the form. In the Properties Sheet of the List do the following:

    a. In the Data tab, set the RowSourceType to 2-Alias and the RowSource

          to customer.cust_id.
    

    b. In the Other tab, set MultiSelect to true (.T.) and the Name to

          lstCust_id.
    

  4. Add a new property to the form. In the New Property dialog box, type:

    achosen[1]

  5. Add a command button to the form. Type the following code into its Click event:

    local lnCounter lnCounter = 0 DIMENSION ThisForm.achosen[ThisForm.lstCust_id.ListCount] WITH ThisForm

          FOR i = 1 TO .lstCust_id.ListCount
    
             IF .lstCust_id.Selected(i)
                lnCounter = lnCounter + 1
                .achosen[lnCounter] = .lstCust_id.List[i]
             ENDIF
          ENDFOR
       ENDWITH
       IF lnCounter = 0
         WAIT WINDOW "No Records Chosen !"
       ELSE
          DIMENSION ThisForm.achosen[lnCounter]
          REPORT FORM CustRepo FOR ASCAN(ThisForm.achosen,cust_id) > 0 PREVIEW
       ENDIF
    


Additional reference words: 3.00 3.00b VFoxWin
KBCategory: kbprg kbhowto kbcode
KBSubcategory: FxprgGeneral


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 23, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.