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

Printing Selection Criteria on a report. 2

Status
Not open for further replies.

mrshardee2

Technical User
May 24, 2004
29
US
I have a report in Crystal 8.5 that shows Anesthesia Types selected by Anesthesiologist, OR Suite, Patient Type, etc. I would like to show in the footer of the report the criteria that the user selects to print the report. The only parameter that I can get to print on the report is the Beginning Date and the Ending Date. Everything else prints blank, even though the data is showing (so I know the parameters are working to select data).

Thanks!


Amber [peace]
 
If you are trying to print a muliple valued parameter simply by dragging it onto the report canvas it will only show the last value selected.

You need to create a formula field that uses "WhilePrintingRecords", appends each new value to the string of previous, and then suppress all but the last one.

I will try to find an example,
 
OK, I tried this:

WhilePrintingRecords:
shared x as string:
dim i as number:
i = 1:
for i = 1 to count({?practid})
x = x + {?practid}(i) + ", ":
Next

I get the error "A string is required here" for my parameter in line 6.

I tried to change it to text:

WhilePrintingRecords:
shared x as string:
dim i as number:
i = 1:
for i = 1 to count({?practid})
x = x + totext({?practid})(i) + ", ":
Next

I get the error "A number, currency amount, boolean, date, time, date-time, or string is required here."

What am I doing wrong?


Amber [peace]
 
For string parameters, you can use:

join({?parameter},", ")

For number parameters, you can use:

whileprintingrecords;
stringvar parm;
numbervar counter;
numbervar i := ubound({?prod ID});

for counter := 1 to i do(
parm := parm + totext({?prod ID}[counter],0,"") + ", ");
left(parm, len(parm)-2);

Substitute your parameter field for {?prod ID}.

For date range parameters, you can use:

totext(minimum({?daterange}),"MM/dd/yyyy")+" to " +
totext(maximum({?daterange}),"MM/dd/yyyy")

-LB
 
I tried that coding (my parameter is a number), but I get the error "The remaining text does not appear to be part of the formula". ????????????????????????????????????????

Amber [peace]
 
I should have been more clear - the error is pointing to the end of line 1.

Amber [peace]
 
You need a ; not a : at the end of WhilePrintingRecords - you don't have this in your example, do you have the same mistake in the formula?
 
When I put the semicolon after WhilePrintingRecords, I get the error "The remaining text does not appear to be part of the formula" at the semicolon.

Amber [peace]
 
Sorry - as it's Basic syntax see what happens when you remove all the semicolons?
 
After WhilePrintingRecords, I get the error "A statement is expected here".

Amber [peace]
 
Try lbass's example:

whileprintingrecords;
stringvar parm;
numbervar counter;
numbervar i := ubound({?prod ID});

for counter := 1 to i do(
parm := parm + totext({?prod ID}[counter],0,"") + ", ");
left(parm, len(parm)-2);

But change your syntax to Crystal rather than Basic. Or was there a reason why you chose Basic?

 
I have tried using both Crystal and Basic Syntax, but I get errors with both.

Amber [peace]
 
That works fine with me - that's really odd! Have you definitely used a semicolon rather than a colon?
 
This is my coding:

whileprintingrecords;
stringvar parm;
numbervar counter;
numbervar i := ubound({?practid});
for counter := 1 to i do(
parm := parm + totext({?practid}[counter],0,"") + ", ");
left(parm, len(parm)-2);
----------------------------------------------------
I get the error "A number, currency amount, boolean, date, time, date-time, or string is required here."

This error occurs before my second parameter.

Amber [peace]
 
Sorry about this but that works fine for me!
I'll keep looking
 
OK, I think I figured out what my problem is. My parameter was formatted to allow discrete AND range values. Once I took the 'Range' option off, I quit getting errors! [2thumbsup]

Amber [peace]
 
OK, now that I've got that working - One more question:

How do I link that parameter to a data field? For example, my parameter is pulling all practitioner IDs, but I want to list the practitioner name in the footer. I have the two tables linked, but when I try to pull the paractname into the formula, I get M,I,C,H,A,E,L,,,K,I,D,D,etc.

Amber [peace]
 
Probably barging in where I'm not needed, as Katy seems to have this under control here, but I'm just wondering: why do you need to put the practitioner name in the formula?

I'm assuming that there is a direct one to one relationship between PractitionerID and PractitionerName, so you shouldn't need to make any reference in a formula to the name. You could just drag the raw database field PractitionerName into the report, and it'd always reflect the relevant name to the current ID.

Naith
 
The following code works in the report header or footer, but is basically a hard coding of the parameter descriptions:

whileprintingrecords;
stringvar parm;
numbervar counter;
numbervar i := ubound({?practid});

for counter := 1 to i do(
parm := parm +
(
if {?practid}[counter] = 101 then "Dan Brown" else
if {?practid}[counter] = 102 then "Alice Munro" else
if {?practid}[counter] = 103 then "Michael Connelly"
)
+", ");
left(parm, len(parm)-2);

Alternatively, you could accumulate the practitioners' names that appear on the report using a manual running total, but you might run into the 254-character limit since you are using 8.5.

To do this, use the following formula in the report footer:

whileprintingrecords;
stringvar names;

if instr(names,{table.name}) = 0 then
names := names + {table.name} + ", " else
names := names;
left(names,len(names)-2);

This would not list parameter selections that did not appear on the report because records did not meet other selection criteria.

-LB
 
I tried this:
whileprintingrecords;
stringvar names;

if instr(names,{psmresindstaff.res_abbr}) = 0 then
names := names + {psmresindstaff.res_abbr} + ", " else
names := names;
left(names,len(names)-2);

I'm only getting the first practitioner.

Amber [peace]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top