Page 1 of 1

Page Numbers in Custom Reports

Posted: Sat Dec 16, 2006 6:57 pm
by bobfree
I am looking for the way to insert page numbers in custom reports in the form of "Page __ of__". I can get the individual page number without any problems but have not been able to get the Page__of__ to display.
Any help will be appreciated.

Bob Freeman

Posted: Mon Dec 18, 2006 8:54 am
by Zorak
Use the following:

Code: Select all

"Page "+_PAGENO+" of "+_PAGETOTAL

Posted: Tue Dec 19, 2006 11:32 am
by bobfree
I agree that the expression provided should do the trick. However, I am getting an error when using it. I can get any one part of the expression to run and produce the proper information but when I combine them into the complete expression I get the following:
PROGRAM: QM_RTYPE
Line: 3000
Error: 107
Message: Operator/operand type mismatch.

Further help will be greatly appreciated.

Bob Freeman

Posted: Tue Dec 19, 2006 5:43 pm
by Zaphod
Sorry - you're getting that message because you're trying to add numbers to letters, and math doesn't work that way, unless it's algebra.

What you need is:

Code: Select all

"Page "+STR(_PAGENO)+" of "+STR(_PAGETOTAL)
You have to convert those numbers to strings so they concatenate properly.

Posted: Tue Dec 19, 2006 6:28 pm
by bobfree
Thanks Zaphod you are right on!
Conversion of numbers to strings is indeed necessary for them to work in the expression. The expression that you provided does provide the results I am looking for. However, I do still have a format problem if you could steer me in the right direction. It seems that in each case where the string command is issued there are 6 or 8 spaces added in the displayed information.
Looks like - Page 1 of 12.
I thought I might be able to correct this with the TRIM command but could never get it just right. It appears to process in the expression, but the spaces are still be there.

Thanks,
Bob Freeman

Posted: Tue Dec 19, 2006 6:33 pm
by bobfree
Zaphod
I just looked at my previous post and in the line that says 'Looks like" there should have been 6 or 8 spaces between "Page and 1" and again between
"of and 12". The spaces were remove when I posted the message.
Thanks,
Bob

Posted: Tue Dec 19, 2006 7:11 pm
by bobfree
Zaphod
I have been doing some more research and have now got the solution to my problem. I made some changes to the expression you provided and now have the correct data in the correct format.
Following is the revised format of the expression:
"Page "+LTRIM(STR(_PAGENO))+" of "+LTRIM(STR(_PAGETOTAL))

Thanks again for your assistance.

Bob Freeman

Posted: Wed Dec 20, 2006 12:42 am
by Jeff
You can also use the transform function. The syntax is TRANSFORM(vExpression). It automatically changes any type into a character string. In the case of numeric values, it automatically trims the function.

In your example, it would be "Page "+TRANSFORM(_PAGENO) + " of " + TRANSFORM(_PAGETOTAL)

Posted: Wed Dec 20, 2006 8:04 am
by bobfree
Thanks a bunch for the info.

Bob

Posted: Wed Dec 20, 2006 11:03 am
by Zorak
Sorry for my initial incorrect post!