Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

printing report

Status
Not open for further replies.

ivatanakoo

IS-IT--Management
Oct 9, 2014
23
PH
i have table name issue
fields
id name item aqdate number price
sample records
1 bryan laptop 10/10/14 ARE#14123BY 10000
2 simon desktop 10/10/14 ICS#14321SY 10000
1 bryan van 10/10/14 ICS#14123BY 5000

want:
when i filter name bryan or number ARE#14123BY
filter number or the name and determine if price is greater than 10000 then prints record (ARE)
and if less than 6000 than prints different report (ICS)

sample print1
1 bryan laptop 10/10/14 ARE#14123BY 10000
sample print2
1 bryan van 10/10/14 ICS#14121BY 5000

SELECT issue
SET ORDER TO name
LOCATE FOR issue.price > 10000.0000
IF FOUND()
REPORT FORM c:\inventory_system\reports\are.frx PREVIEW FOR name = issue.name

else...
 
Seems like you don't want to print a different report just different data.

So the main logic would be

Code:
SELECT table
SET FILTER TO name = issue.name and price>10000
LOCATE 
IF NOT FOUND()
   SET FILTER TO name = issue.name and price<6000
   LOCATE
ENDIF

IF EOF()
   Messagebox("Neither condition fits to any data")
ELSE
   REPORT FORM c:\inventory_system\reports\are.frx PREVIEW
ENDIF

Bye, Olaf.
 
actually i want to print different report,
if price is greater than 10000
then prints are.frx report of the selected name with the same number
elseif price is less than 6000
then prints ics.frx report of the selected name with the same number
else
messagebox(no report)
endif
tnx sir olaf..
 
Unless you wish to print out a separate report for each separate record which matches your conditions, you will want to gather together the records into 'sets' where each record group matches one of your conditions.

Code:
* --- Set Default Flag Variable ---
m.ReportFlag = .F.

* --- Gather ALL Records matching First report criteria ---
SELECT *;
 FROM Issue;
 WHERE Price > 10000;
 AND <any other unique selection criteria>;
 INTO CURSOR ReportData1

* --- If Any Records Present, Print Them ALL ---
SELECT ReportData1
IF RECCOUNT() > 0
   REPORT FORM Are.FRX TO PRINTER
   m.ReportFlag = .T.
ENDIF
USE

* --- Gather ALL Records matching Second report criteria ---
SELECT *;
 FROM Issue;
 WHERE Price < 6000;
 AND <any other unique selection criteria>;
 INTO CURSOR ReportData2

* --- If Any Records Present, Print Them ALL ---
SELECT ReportData2
IF RECCOUNT() > 0
   REPORT FORM Ics.FRX TO PRINTER
   m.ReportFlag = .T.
ENDIF
USE

* --- If Nothing Printed, Display MessageBox() ---
IF !m.ReportFlag
   * --- Display 'No Report' Message Box ---
ENDIF

Obviously this simple example code can be modified in any other way that you need.

Good Luck,
JRB-Bldr



 
So, if you found a rpice>10000 then print are.frx, nothing is impler than that with a simple change of the program flow, using ELSE.

Code:
SELECT table
SET FILTER TO name = issue.name and price>10000
LOCATE 
IF FOUND()
   REPORT FORM c:\inventory_system\reports\are.frx PREVIEW
ELSE && that means NOT FOUND()
   SET FILTER TO name = issue.name and price<6000
   LOCATE
   IF FOUND()
      REPORT FORM c:\inventory_system\reports\ics.frx PREVIEW
   ELSE && not found either:
      Messagebox("Neither condition fits to any data")
   ENDIF
ENDIF

Warning: I think your description of what you want still has a logical flaw, as this will only print the ics report, if there are no records for the are report. I can't judge though, if that's wrong or right, you have to decide it yourself.

I think you think too complicated and rather want to simply print two types of reports for data with ARE and ICS in their number field respectively, then simply apply the two conditions and print the corresponding report.

In all simplicity that would only need:
Code:
SELECT table
SET FILTER TO LEFT(number,3)=="ARE" && <-- apply further conditions about issue.name etc here
REPORT FORM c:\inventory_system\reports\are.frx PREVIEW
SET FILTER TO LEFT(number,3)=="ICS" && <-- apply further conditions about issue.name etc here
REPORT FORM c:\inventory_system\reports\ics.frx PREVIEW

Bye, Olaf.
 

sir olaf:
REPORT FORM c:\inventory_system\reports\ics.frx PREVIEW
this will print all the data on the table.

by the way tnx...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top