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

String erorr in sub-report group footer

Status
Not open for further replies.

hlb6

Technical User
Aug 2, 2013
27
US
I keep getting this "A string is required here", error (on the last if statement, ({@count2})) on this formula (I hope I am giving you enough information):

If {?p_Department} = "Yes" and
{?p_Excel} = "Yes" then {?p_Excel}
Else (If ({?p_Technician}={Command.usr_id})Then
(If({?p_Excel} = "No") then
(if({@Count1} > 1) and
(isnumeric({@UserIdSum2}))=True
then
(Val({@UserIdSum2})))))

This is being on a sub-report (mind you I am trying to fix someone else's work with no comments as to what and where things are).

Here are the formulas the are refered to within this statement:
{@Count1} =
if (Count({Command.usr_id},{Command.usr_id})> 1)
Then 1
Else 2;

{@count2} =
if ({@Count1})=1
Then "Yes"
Else "No";

{@UserIdSum2}=
WhilePrintingRecords;
Global numbervar TechSum:=
(Sum ({@BATSV}, {Command.usr_id});
Sum ({@BERV}, {Command.usr_id});
Sum ({@BML}, {Command.usr_id});
Sum ({@BLUE}, {Command.usr_id});
Sum ({@DEMO}, {Command.usr_id});
Sum ({@FL}, {Command.usr_id});
Sum ({@HL}, {Command.usr_id});
Sum ({@HOLI}, {Command.usr_id});
Sum ({@INJRY}, {Command.usr_id});
Sum ({@JURY}, {Command.usr_id});
Sum ({@LTR HL}, {Command.usr_id});
Sum ({@M RENT}, {Command.usr_id});
Sum ({@NEW E}, {Command.usr_id});
Sum ({@AFA}, {Command.usr_id});
Sum ({@NPL}, {Command.usr_id});
Sum ({@PM}, {Command.usr_id});
Sum ({@PL}, {Command.usr_id});
Sum ({@PRT DR}, {Command.usr_id});
Sum ({@PERSL}, {Command.usr_id});
Sum ({@RECAP}, {Command.usr_id});
Sum ({@RESTK}, {Command.usr_id});
Sum ({@SFTY}, {Command.usr_id});
Sum ({@SALES}, {Command.usr_id});
Sum ({@ST}, {Command.usr_id});
Sum ({@SL}, {Command.usr_id});
Sum ({@SHOP M}, {Command.usr_id});
Sum ({@S TRNG}, {Command.usr_id});
Sum ({@SICK}, {Command.usr_id});
Sum ({@SPS}, {Command.usr_id});
Sum ({@STR HL}, {Command.usr_id});
Sum ({@SUP}, {Command.usr_id});
Sum ({@TIRE P}, {Command.usr_id});
Sum ({@TL SUP}, {Command.usr_id});
Sum ({@TRN}, {Command.usr_id});
Sum ({@USED E}, {Command.usr_id});
Sum ({@UTLTY}, {Command.usr_id});
Sum ({@VAC}, {Command.usr_id});
Sum ({@TotHours}, {Command.usr_id}));

All of the Sum({@XXXX) =

WhilePrintingRecords;
numbervar AFA := 0;

AFA := sum({@AFA},{Command.bra_id});

If AFA >= 1 then
Totext(fix (AFA),0) + "." + Totext(Remainder(AFA,fix (AFA))*60 ,0)
else if (AFA < 1 and AFA > 0) Then
"." + Totext(AFA*60 ,0)
else
Totext(fix(AFA),0)


 
Both sides of a If statement have to 'return' the same data type.

If {?p_Department} = "Yes" and
{?p_Excel} = "Yes" then {?p_Excel}
Else (If ({?p_Technician}={Command.usr_id})Then
(If({?p_Excel} = "No") then
(if({@Count1} > 1) and
(isnumeric({@UserIdSum2}))=True
then
(Val({@UserIdSum2}))))) It appears that [?p_Excel] is a string, thus Val({@UserIdSum2} has to be a string (example ToText(Val({@UserIdSum2}))
 
Yes I understand - how do I fix it??????
 
It appears that @UserIDSum2 is string, is there a particular reason to make it numeric?
 
This is what I am trying to achieve:
If the user selects “Yes” on the Department Parameter, then the Group header is not suppressed , it shows the Department and each user-id (they are not numeric: if they were that would make this a lot easier!) is listed under that department with their information.
I.e.:
PHa: column names
GH3 (Department, shows if “Yes” otherwise suppressed, Grouped on department)
GF4a (user-id: Group is on user-id):
Now if (?Department ) = No and user-id = user-id and count(user-id) > 1 then
Suppress GH3, and group each user-id with their total on one line otherwise leave it alone.
Unsuppressed example (Yes is selected on Department)
025
jaragon 0 0 0 0 0 0 34.30
jevans 0 0 0 0 0 0 44.0
Dept Totals 0 0 0 0 0 0 78.30
040
ccochran 0 0 27.0 1.0 0 0 0
dsouthard 0 0 3.0 0 0 0 0
ebeetso 0 0 0 0 0 0 0
jaragon 0 0 0 0 0 0 48.0
jevans 0 0 0 0 0 0 33.30
Additional users where listed so under 040 there would be a group total for the department

Now from the example above, I need to have the following only show when No is selected on the Department parameter:
Suppress GH3 (025, 040 These are the departments)
On GF4a I need to have each userid grouped and summed in each column:
Jaragon in 040 and 025 needs to be grouped and summed

Jevans in 040 and 025 needs to be grouped and summed

I hope you understand this
 
Not quite, not quite sure where the {?p_Excel} parameter comes in. Also I am not sure what you are trying to achieve with the first formula. The formula is stating that if {?p_Excel} and {?p_Department} are yes then show {?p_Excel} else do some other checks (({?p_Technician}={Command.usr_id})Then (If({?p_Excel} = "No") then (if({@Count1} > 1) and (isnumeric({@UserIdSum2}))=True), if all of that is true then show the value (i.e., convert the result of {@UserIdSum2} to a number), but do not understand why it needs to be numeric.
 
Okay-

from what I am told it is a formatting thing - there are two groups in group 4 that are grouped on user-id:

{?Excel) is Boolean

4a: which states originaly that if the user selects true on {?Excel}then it will show everything headers, column names, etc
selection expert suppress button X = ({?p_Excel})

4b: states if the user selects the false then only the data shows. Within the GF selection expert suppress button X = Not({?p_Excel})


I was now asked to add a parameter for department ({?p_Department} which I made a string) - if the user selects yes then show by department
if no then group by the user-id and sum their totals in each column and do not group by department

Still confused
 
Remember that Group #3 is the Department grouping
 
The results of the if statement have to be the same data type. Since {?p_Excel} is result of the first then, thus all other results from IF's (else's) have to be the same data type as the {?p_Excel}. I am not clear what this formula is supposed to accomplish.
 
The Excel Parameter is for exporting to excel
 
If the user wants to export - just the data it keeps the excel formatting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top