Link to home
Start Free TrialLog in
Avatar of Bryan OConnell
Bryan OConnellFlag for United States of America

asked on

docmd.printout - page range data type limitation?

ms access 2007

i have a report that is 42000 pages long.  i am trying to use vba to print out specific ranges of pages (spreading print job across multiple printers).

when i try to print a range with a starting or ending page number over 32768, i get an error stating data type error with one of my arguments.   it is happening with this line:

docmd.printout acPages, pageLow, pageHigh

both pageLow and pageHigh are declared as Long, i've also tried Variant.

i also tried:
docmd.printout acPrintAll

but, that only prints out 32767 and stops (without error)


if there is a limitation with the data type in the command, is there a workaround?

if i do it manually with the print window (ctrl-p), it has no problems doing it.

what am i missing?

thank you.
ASKER CERTIFIED SOLUTION
Avatar of Jim P.
Jim P.
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
deputycollector,

What manner of report is this?

Can you try breaking it up into seperate reports (or filtering it)?

For example, if this report is "All Collections" you could possibly break it down by State, Or Date Range, or Type of Collection.
Then print each individually.

JeffCoachman
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bryan OConnell

ASKER

boag2000 - unfortunately, the nature of the job doesnt break up that easily.  it would be a last resort and something i have have considered, but, is not desirable given the

grayl - there is nothing that increments per page that is programmatic in nature.  the only incrementing item would be [Page], but, that seems to work fine over 32767.  however, the [Pages] value does not...it actually goes negative (overflow?) with pages higher than 32767.

the irritating thing is that the documentation calls out the data types as Variant and therefore i would have assumed i would be ok.

jimpen - i'll try and report it.

hopefully, someone else might have a magical fix/tweak???

i am thinking i might have to resort to some sort of SendKeys sequence to use the real print dialog, but, i am "learning" my way thru that one as we speak.
...And simply calling up the Print Dialog box is not an option?

Dim strRptName As String

strRptName = "YourReport"
   
    'Turn off the screen
    DoCmd.Echo False
    'Open the report
    DoCmd.OpenReport strRptName, acViewPreview
    'Open the Print Dialog box
    DoCmd.RunCommand acCmdPrint
    'Close the report
    DoCmd.Close acReport, strRptName
    'Turn the screen back on
    DoCmd.Echo True

End Sub

You could get crazy and try SendKeys, but I would not trust it with dialog boxes.

Going further even further out, you could try converting the Report to a PDF file , then try to automate the printing Via some Adobe hook.
http://www.adobe.com/devnet/acrobat/pdfs/iac_api_reference.pdf


JeffCoachman


There's the problem.  For some dumb reason, In Access 2003, Page is a Long variable whereas Pages is Integer and of course limited to 32767.  It looks like  they did't fix it in Access 2007.
>> In your referenced link, your post was the "Accepted"
>> solution, yet you were awarded 0 Points?

Jeff,

I was also the asker of the Q. I was awarding points just for other experts taking a look.
Type Alt+F11 to get to the VBA Editor window and type 'Page' in the Help window.  Look at both the Page Property and the Pages collection.  In A2003 Page is Long and Pages is Integer.  Confirm that Access 2007 types both as Variant?
Jim,
   
<I was also the asker of the Q. I was awarding points just for other experts taking a look.>

OIC

;-)

Jeff
Have you considered dumping it to something like PDFCreator and then printing from the PDF?
grayl - access 2007 does identify the Pages parameter as an Integer (read/write).  however, the Docmd.Printout page indicates the data types of the start and ending pages should be Variant...making one think it is ok to try a Long range.

jimpen - ironically, this ordeal started with an attempt to print the entire thing to pdf. when using the PrinOut method, regardless of the destination, stops at 32767.  the pdf printer is the printer i need to get it working to, but, the problem appears to be at a lower level (since it doesnt work to any printer type).

boag - calling up the print dialog is fine, but, since i dont want user intervention, i need the SendKeys (or similar) technique to work, and i had (and have) been struggling to get that to behave properly for some reason.

i have resorted to the split the print job into multiple jobs.   takes much longer, but, it gets me to my destination.

basically, i print the job to multiple pdfs, then i have another process (perl) that uses "pdftk" to break it up into individual pages, that then get named using the sort key from the original print job.  end result gets the pages individually searchable/retrievable by another web based search program.

pain in the arse, but, i will get it to work with this less than desirable approach.

i appreciate all the feedback.
Thanks,

But you could have really split the points.

The other experts here also contributed very useful information.
Please click the "Request Attention" button to split the points.

;-)

Jeff
ok.  thank you for the suggestion.  and, sorry for the confusion.
Yes,
For example, I did not know of the Datatypes involved with these values.
This info, pointed out by the other experts, is useful info, and should be noted.

;-)
I'm feelin' the Love!
;-)
Glad to be of assistance. May all your days get brighter and brighter.