Suprisingly, the only way I know to do this is with a global field and a script that previews your report and then counts the pages:
Define a global field for the total pages, gTotalPages.
Place this field in your layout where you want to see this number.
#modify this script to first perform any find and/or sort needed to set up the report
Enter Preview Mode
Go To Record/Page/Request [last]
Set Field [YourTable::gTotalPages ; Get ( PageNumber ) ]
#Now you can print or pause the script while still in preview mode to give the user the option to print, save as PDF or return to browse mode
I tried the script noted above because I'm trying to add page numbers to a layout and I got it to work, even though I set it to start at the first page, instead of last. But I've tried it either way and it still doesn't show the page number in Preview mode, if it's supposed to. So how do I fix this and does this script automatically run when I do print the records from the layout where I placed this field?