Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2003
    Posts
    43

    Printing a Form from Access

    I know that a form is not suppose to be used for printing and rather have a report created to do the work for printing. However all of the users choices are done on the report and their is no good way I can think of to pass the control data from the form to a report without having to recreate the whole form in reporting.

    My issue is that no matter what DoCmd.Printout I use I am getting one of two errors.

    1. "The PrintOut Action was Cancelled"
    2. Index or key field can not be null. (this is because I do not want the end user to save the data back to the tables and have turned off saving the form.

    Any thoughts on how to get around this or another command I could use to get the form and my charts on the form to print?

    Bill

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,100
    Care to paste the offending code?
    After a very quick test, simply using
    Code:
    DoCmd.Printout
    with no parameters, appeared to do the trick for me.
    George
    Home | Blog

  3. #3
    Join Date
    Oct 2003
    Posts
    43
    George,

    Here is the code:

    Private Sub cmdPrint_Click()

    On Error GoTo Err_cmdPrintPre_Click

    DoCmd.PrintOut acPrintAll

    Exit_cmdPrintPre_Click:
    Exit Sub

    Err_cmdPrintPre_Click:
    MsgBox Err.Description
    Resume Exit_cmdPrintPre_Click

    End Sub

    When I try to use just DoCmd.PrintOut I am getting error #1, when I do anything else under the DoCmd structure I am getting error #2. Note that this form does have a form on it as well as controls.

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,100
    Have you got a default printer set?
    What happens when the form is open and you click the print button off the access toolbar?

    http://www.programmingtalk.com/showthread.php?p=142134
    George
    Home | Blog

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,100
    And I would just like to voice my opinion of making reports instead of printing the form.

    1) a lot clearer
    2) uses less ink
    3) avoids these painful problems ()
    George
    Home | Blog

  6. #6
    Join Date
    Oct 2003
    Posts
    43
    Quote Originally Posted by georgev
    Have you got a default printer set?
    What happens when the form is open and you click the print button off the access toolbar?

    http://www.programmingtalk.com/showthread.php?p=142134
    Yes I have a default setup. It prints a blank page.

  7. #7
    Join Date
    Oct 2003
    Posts
    43
    Quote Originally Posted by georgev
    And I would just like to voice my opinion of making reports instead of printing the form.

    1) a lot clearer
    2) uses less ink
    3) avoids these painful problems ()

    I do not disagree

    Unfortunatly for some reason I can not tie the same control functions into a report that I can a form...

  8. #8
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Yeah, beats me... I NEVER print forms.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  9. #9
    Join Date
    Oct 2003
    Location
    Chicago, IL
    Posts
    34
    Seeing that you are getting the same response on dbforums as you are on programmingtalk, I would say perhaps its time for you to re-think your setup Bill.

    Pete
    DigiOz Multimedia
    http://www.digioz.com

Posting Permissions

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