Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Sep 2003
    Location
    London, Gtr London, United Kingdom
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Printing Forms (a2002)

    I know that it is not normally recommended to print forms but that is what I need to do, however I need to print 3 copies of a particular form and would like to automate a print button to do that.

    I have inserted on my form a print button using the wizard and then chaged the 'On Click' event procedure as follows

    Private Sub Command7_Click()
    On Error GoTo Err_Command7_Click

    Dim stDocName As String
    Dim MyForm As Form

    stDocName = "frmDGNote"
    Set MyForm = Screen.ActiveForm
    DoCmd.SelectObject acForm, stDocName, True
    DoCmd.PrintOut acPages, page 1, to page 1 ,,3 copies
    DoCmd.SelectObject acForm, MyForm.Name, False

    Exit_Command7_Click:
    Exit Sub

    I found this code whilst surfing about but it does not seem to like the line

    DoCmd.PrintOut acPages, page 1, to page 1 ,,3 copies

    I changed the form name to frmDGNote which is relevant to my form but I don 't know if there is any other reference in this code that needs to be changed.

    Any help appreciated

    Thanks

    Steve

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Printing Forms (a2002)

    VBA may resemble English, but you can't just use phrases like page 1, to page 1 ,,3 copies. Use this instead

    DoCmd.PrintOut acPages, 1, 1 , , 3

    or

    DoCmd.PrintOut PrintRange:=acPages, PageFrom:=1, PageTo:=1, Copies:=3

  3. #3
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing Forms (a2002)

    Stephen
    You could try the following:

    DoCmd.PrintOut acPages, page1, page3, acDraft, 3

    I edited this from your code and it doesn't highlite in red.

  4. #4
    2 Star Lounger
    Join Date
    Sep 2003
    Location
    London, Gtr London, United Kingdom
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing Forms (a2002)

    Thanks both of you for the prompt response, however trying all 3 alternatives cures the problem of it being highlighted red, however the form does not print at all. Is there something else I need to do?

    Cheers

    Steve

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Printing Forms (a2002)

    Which form do you want to print? Is "frmDGNote" the form containing the command button, or is it another form?

  6. #6
    2 Star Lounger
    Join Date
    Sep 2003
    Location
    London, Gtr London, United Kingdom
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing Forms (a2002)

    Hi Hans

    Yes the form is indeed frmDGNote and it contains the print button with the code in the 'On Click' event procedure

    Thanks

    Steve

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Printing Forms (a2002)

    In that case, remove the two lines beginning with DoCmd.SelectObject. They were meant for printing another form. Some other things can be scrapped too.

    Private Sub Command7_Click()
    On Error GoTo Err_Command7_Click
    DoCmd.PrintOut acPages, 1, 1 , , 3
    Exit Sub

    Err_Command7_Click:
    MsgBox Err.Description
    End Sub

  8. #8
    2 Star Lounger
    Join Date
    Sep 2003
    Location
    London, Gtr London, United Kingdom
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing Forms (a2002)

    Hi Hans

    Thanks, worked like a charm, I can see that on my next trip to Holland it will cost me a fortune in Roll Mops and Grolch <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15>

    Steve

Posting Permissions

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