Total pages in Access report showing as negative number (1 Viewer)

isladogs

CID Moderator
Staff member
Joined
Jan 14, 2017
Messages
12,357
Here's a strange issue I've not seen before
I have a report with a very large number of records
Filtered = 1758312 records ; Unfiltered = 2604721

I don't want anyone to print the report 'by accident' so I want the total number of pages to be displayed

In both cases the standard 'page of pages' footer shows as a negative number.



Also peculiar is that the filtered report with fewer records is more negative

My initial guess was that the built in Pages function is an integer & that the total pages had exceeded the integer value limit (32767) & somehow restarted from the negative integer limit

Having checked there are 47 records per page, so I've done a calculation of what I'd expect the result to be in each case.



So it does exceed the integer limit in each case but I still can't make sense of the valuers shown.
Can anyone else explain what is happening.
Even better can anyone give me a solution (apart from hide the '& Pages')
 

Attachments

Last edited:

jdraw

Super Moderator
Staff member
Joined
Jan 23, 2006
Messages
12,587
Colin,

I saw this at stackoverflow


Code:
I found a clue on this page:

http://www.sqldrill.com/excel/access-reports/695207-access-prints-negative-number.html

But the expression wasn't 100% so I had to modify it:

="Page " & [Page] & " of " & IIf([Pages]<1,(32768-Abs([Pages]))+32768,[Pages])

Page numbers appear to be correct now. :)
 

isladogs

CID Moderator
Staff member
Joined
Jan 14, 2017
Messages
12,357
Jack

Once again you are an absolute star.
I had spent ages searching for this topic without a single hit!

The link to SO didn't work for me however

Your solution not only works - as you say it gives EXACTLY the number of pages that my earlier calculation predicted.
The solution also confirms my original supposition about integer limits

I just hope nobody ever tries to print a report with 55420 pages



EDIT - just tried to award you well deserved RPs but it still won't allow me to do so - there must be a point after which old RPs are deemed to have lapsed
 

Attachments

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom