Results 1 to 7 of 7
  1. #1
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Manipulating report printing (Access 97/SR2)

    I have made a report that is run from a form - basically, a button on the form populates an unbound textbox with an EstablishmentID. The report is then a list of establishments with the one on the form highlighted. The button press on the form now prints the report directly (not preview) and moves onto the next record before repeating the process.

    However, this works out at 15000 pages of reports, which the client has decided is too much. They now want only the corresponding page of establishments (i.e. out of 37 pages, the page with the estab. given on the form) printed.
    I've made plenty of reports, but haven't yet had any experience with manipulating page numbers i.e. only printing certain ones - i'm not even sure it's possible.

    If anyone can point me in the right direction (a suitable word to look up in the help file will do!) to fixing this problem it would be much appreciated.

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Manipulating report printing (Access 97/SR2)

    I know you could use
    <pre>Docmd.PrintOut acPages, x, y</pre>

    to print pages from x to y, but how will you determine witch page numbers to be printed ?

    Why don't you put a where condition on the report
    If EstablishmentID is a number :
    <pre>Docmd.OpenReport "YourReport", acViewNormal, , _
    " EstablishmentID = " & forms!YourForm! EstablishmentID</pre>

    If EstablishmentID is a string :
    <pre>Docmd.OpenReport "YourReport", acViewNormal, , _
    " EstablishmentID = '" & forms!YourForm! EstablishmentID & "'"</pre>

    Francois

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Pass a WhereCondition (Access 97/SR2)

    You don't print just certain pages, you limit the report to the records you want. Just pass a WhereCondition string the the report in the OpenReport call. It would look something like this:

    DoCmd.OpenReport "MyReport", , , "[EstablishmentID]=" & Me![txtEstablishmentID]

    This assumes that "MyReport" is the name of the report being opened and that the recordset of the report contains a numeric field named EstablishmentID and the form has a control named txtEstablishmentID that contains the current value you want to use.

    Page numbers will start at 1 because they are generated on the fly, not actually related to anything in the data.
    Charlotte

  4. #4
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Pass a WhereCondition (Access 97/SR2)

    Thanks for your replies. I thought limiting the report might be the way to go. Incidentaly, this ties in with my latest post titled "Printer settings", as the costs of the extra programming are now being weighed up against the cost of paper and with duplexing printing halfing the amount of paper used.

    The page numbers won't be a problem as they're not on the reports. However, to get all of the establishments that would be on the page if the whole report was printed i'd have to make some sort of equation i.e. Count the records previous to the one highlighted, divide it by the number of records per page and select only records after that one - I should be able to get that working.

    I'll have to have a go at something with the Docmd.PrintOut acPages, x, y though - might come in handy one day - thanks again for your help.

  5. #5
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Manipulating report printing (Access 97/SR2)

    I thought I'd have a go at using the "Docmd.PrintOut acPages, x, y" code for printing my report. I have worked out which page numbers are needed, however, I didn't realise that you can't specify the report to be printed like when using docmd.openreport!
    Is there any way of doing this for the PrintOut function? As the code is run from a form, I currently just get printouts of the form screen.

  6. #6
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Manipulating report printing (Access 97/SR2)

    Phil,

    You have to use the docmd.openreport.
    <pre>DoCmd.OpenReport "ReportName", acPreview
    DoCmd.PrintOut acpages, x, y
    </pre>

    The preview window will open, and then be closed by the printout command
    Francois

  7. #7
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Manipulating report printing (Access 97/SR2)

    Thanks Francois, that works perfectly.

    I think docmd.PrintOut will turn out to be a very useful command to me!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •