Microsoft KB Archive/147310

= How to print a report that is based on selections in a list in Visual FoxPro =

Article ID: 147310

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Visual FoxPro 7.0 Professional Edition
 * Microsoft Visual FoxPro 8.0 Professional Edition
 * Microsoft Visual FoxPro 9.0 Professional Edition

-



This article was previously published under Q147310



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.



Step-by-Step Example
This example uses the Customer table from Testdata.dbc database in the \Samples\Data subdirectory.  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. Create a new form, and add the Customer table to the Data Environment. Add a List to the form. In the Properties Sheet of the List do the following:

 In the Data tab, set the RowSourceType to 2-Alias and the RowSource to customer. In the Other tab, set MultiSelect to true (.T.) and the Name to lstCust_id.  Add a new property to the form. In the New Property dialog box, type:

achosen[1]

</li>  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 </li></ol>

Additional query words: VFoxWin

Keywords: kbcode KB147310

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.