Results 1 to 10 of 10
  1. #1
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Print a Form (Access 2003)

    This is another one of those "I know I've done it before, but can't find it now" questions.

    I open frmQuote.

    I go to a specific record.

    I click a command button which prints frmPrintedQuote reflecting that specific record.

    In this situation, it is not possible to create a rptPrintedQuote, it MUST be a form.

    What I need is the code behind the button that opens the frmPrintedQuote and prints the current record.

    Thanks in advance for any help on this,

    Cheers, <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    Cheers,
    Andy

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

    Re: Print a Form (Access 2003)

    I guess it's better not to ask why you can't use a report... <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    You'd have to do something like this:

    DoCmd.OpenForm FormName:="frmPrintedQuote", WhereCondition:="[RecordID] = " & Me.[RecordID]
    DoCmd.PrintOut
    DoCmd.Close ObjectType:=acForm, ObjectName:="frmPrintedQuote", Save:=acSaveNo

  3. #3
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print a Form (Access 2003)

    Poor Hans!

    You probably rue the day I discovered this Forum.

    First, needless to say, your code worked perfectly.

    The reason for the insistance on using a form instead of a report, is due to the fact that the form I'm printing a user-friendly image of, also contains 3 other subForms that provide data for the main form and it's just a whole lot easier to do it this way. OK, I know, I'm lazy.

    The icing on this cake would be the ability to go into an acPreview mode prior to printing directly, but I'm not sure if that's possible when printing a form.

    Many thanks as always.

    Cheers <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    Cheers,
    Andy

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

    Re: Print a Form (Access 2003)

    You can use

    DoCmd.OpenForm FormName:="frmPrintedQuote", View:=acPreview, WhereCondition:="[RecordID] = " & Me.[RecordID]

    But you'd probably want to omit the lines to print and close the form, and leave it to the user to do that.

  5. #5
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print a Form (Access 2003)

    Thanks, Hans.

    Do appreciate your patience with my anomalous thinking,

    Cheers <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    Cheers,
    Andy

  6. #6
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print a Form (Access 2003)

    Hans,

    Just a further note to describe what you probably already know.

    This one Prints Immediately

    DoCmd.OpenForm FormName:="frmPrintedQuote", WhereCondition:="[RECORDID] = " & Me.[RECORDID]
    DoCmd.PrintOut
    DoCmd.Close ObjectType:=acForm, ObjectName:="frmPrintedQuote", Save:=acSaveNo

    This one allows me to Preview the form first, before sending it to print just as I had asked.

    DoCmd.OpenForm FormName:="frmPrintedQuote", View:=acPreview, WhereCondition:="[RECORDID] = " & Me.[RECORDID]

    When I perform the Preview version, it brings up the correct form for preview, and then I send it to print, and I close the preview. However, and I understand why and you did point this out, the original form itself remains open because it did not get the DoCmd.Close command.

    Always being one that likes to have the cake and eat too, is it possible to go into preview mode, print, and then have it close the form after.

    I tried putting the DoCmd.Close statement after the Preview portion of the code, but when I ran it, it just sailed on past the preview portion and closed the form.

    If not, so be it.

    I hope somebody else is getting as much out of this as I am.

    Cheers, <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    Cheers,
    Andy

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

    Re: Print a Form (Access 2003)

    Do you mean that you want to close frmQuote? Or frmPrintedQuote?

  8. #8
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print a Form (Access 2003)

    frmPrintedQuote
    Cheers,
    Andy

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

    Re: Print a Form (Access 2003)

    The user will have to do that himself.

  10. #10
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print a Form (Access 2003)

    Thanks, Hans, I thought as much.
    Cheers,
    Andy

Posting Permissions

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