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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report Grouping

Status
Not open for further replies.

youwannawhat

Programmer
Oct 3, 2001
43
US
I currently have a veterinary report that prints like this:

Study # A2D

Doctor Animal
______ ______

Jones Rabbit
Jones Guinea Pig
Jones Goat
Smith Rabbit
Smith Guinea Pig
Smith Goat
Adams Rabbit
Adams Guinea Pig
Adams Goat

The user would rather have the report print:

Doctors: Jones, Smith, Adams

Animals: Rabbit, Guinea Pig, Goat

I know this seems simple, but I can't get the report to group the way I want. The data is being pulled from a cursor. I have attempted to manipulate the .prg filling the cursor but have been unsuccessful.

Any suggestions.

Thanks,
 
This may not be exactly what you had in mind but,:

CREATE CURSOR rpt (cData C(80))
SELECT datafile
STORE ALLTRIM(datafile.doctor) TO m.cData
SCAN
m.cData = m.cData + ', ' + ALLTRIM(datafile.doctor)
ENDSCAN
INSERT INTO rpt FROM MEMVAR

GO TOP
STORE ALLTRIM(datafile.animal) TO m.cData
SCAN
m.cData = m.cData + ', ' + ALLTRIM(datafile.animal)
ENDSCAN
INSERT INTO rpt FROM MEMVAR

SELECT rpt
REPORT FORM TheReport

This will give you 2 rows in the cursor you can print.

Dave S.
 
I like Dave's approach, but it doesn't get rid of duplicates. I'd amend it as follows:


CREATE CURSOR rpt (cData C(80))
SELECT DISTINCT doctor FROM datafile INTO CURSOR doc
STORE ALLTRIM(doc.doctor) TO m.cData
SCAN
m.cData = m.cData + ', ' + ALLTRIM(doc.doctor)
ENDSCAN
INSERT INTO rpt FROM MEMVAR

SELECT DISTINCT animal FROM datafile INTO CURSOR an
STORE ALLTRIM(an.animal) TO m.cData
SCAN
m.cData = m.cData + ', ' + ALLTRIM(an.animal)
ENDSCAN
INSERT INTO rpt FROM MEMVAR

SELECT rpt
REPORT FORM TheReport

Jim

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top