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.
- 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:
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.
- Add a new property to the form. In the New Property dialog box, type:
achosen[1]
- 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
|