Results 1 to 15 of 15
  1. #1
    louise is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Apr 2015
    Posts
    112

    Trying to print a report, but get the print of the form instead, and it's for all records

    Hello,


    One of my users has reported a problem that I am unable toreproduce.I am hoping you can give mesome help.

    We have a form for entering registration information, andthen a button (created with the wizard) to create a report/letter to that member,listing that person’s registration information along with various other text.The letter opens in Print Preview, she looksit over, and then on the command line, she clicks Print.

    Sometimes (but not always) an error occurs and she gets aprint out of the form for each record in the dataset.At first I thought she was clicking Print directlyfrom the form, without having the letter in front of her, but she swears not;she is looking at the person’s letter.

    Now, I have learned that another user – with a different datasetentirely, different printer, and even a different approach to generating thereport (this time through an event command, On Click), had a similar problem.When looking at her report on the screen, sheclicked on Print and selected “Print Back and Front” and only some pages – and shegot the same thing:all the forms, not the report.

    Any help or leads would be greatly appreciated!Thanks

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    I use VBA to print reports. You can place code behind a Command Button and send a report straight to the default printer. The trick would be applying a filter to the report so it only prints the desired records. Here is an example that uses a date range.
    Code:
    Dim strWhere As String
    strWhere = "[MyDateField] BETWEEN #" & Me.TextBoxName1 & "# AND #" & Me.TextBoxName2 & "#"
    DoCmd.OpenReport "ReportName", acViewNormal, , strWhere
    PS
    IIRC, acViewNormal will send the report straight to the printer and acViewPreview will open the report in Print Preview mode.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Which won't serve if user wants to review report first.

    What do you mean by 'error occurs' - the error is the printing of form or is there an error message popup?

    What do you mean by 'command line' - button on QAT bar?

    Somehow, the report is losing focus in favor of the form.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by June7 View Post
    Which won't serve if user wants to review report first.
    I am having difficulty putting this in context. Can you elaborate?

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    OP stated "opens in Print Preview, she looksit over, and then on the command line, she clicks Print".
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by June7 View Post
    OP stated "opens in Print Preview, she looksit over, and then on the command line, she clicks Print".
    Still confused. If the statement is in response to my post #2, the statement seems rather dismissive to me. I thought this was worth mentioning in case you did not intend it to be. Also, I did state in post #2 how to use code to open a report in print preview.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Not meant to be dismissive. Just trying to point out to OP that acViewNormal would not first present the report to user to look over. It is certainly an option but doesn't seem like it would meet the needs in this situation.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by June7 View Post
    ... It is certainly an option but doesn't seem like it would meet the needs in this situation.
    Well, I certainly disagree. Code will either send the report directly to the printer or offer a print preview. While in print preview, any interaction with a print command will print the report.

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    So are you suggesting a button to open report in print preview and another to print to printer?

    I still wonder what OP means by "command line".
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by June7 View Post
    So are you suggesting a button to open report in print preview and another to print to printer?
    You would not need a second command button to print from print preview. IIRC, Print Preview is modal and the only thing you can do is zoom, navigate from one page to the next, close, and print. I would venture to guess that if the QAT is still visible it, too, would print the Report. So the User would not have to be retrained.

    The downside to using the code would be building the code and implementing it in the OP's app. As long as they are willing to try it, I feel confident we can help to build the code.


    EDIT: and yeah, not sure what command line is but I would guess the command tool for printing is what they are describing.

    .

  11. #11
    louise is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Apr 2015
    Posts
    112

    Trying to print a report, but get the print of the form instead, and it's for all records - more

    Quote Originally Posted by June7 View Post
    Which won't serve if user wants to review report first.

    What do you mean by 'error occurs' - the error is the printing of form or is there an error message popup?

    What do you mean by 'command line' - button on QAT bar?

    Somehow, the report is losing focus in favor of the form.
    Hello, Thanks for your response,
    - When I said an "error occurs" I meant that the form screen for all records occurs, not that a formal error message appears.
    - By "command line", I meant the Ribbon -- the Print Preview ribbon is showing after the report is opened with the button on the form, and I was referring to the Print option on that ribbon.

    So, what do you think would make the report lose focus? I do have it set up so that the form remains open, since we return to it for other entries after the letter prints. But this happens when she is looking at the letter/report, not the form.

    Here is the code behind the form's button: (so I was not correct in saying this button was set up with the wizard.)
    Private Sub butPreviewLetter_Click()
    'Print Preview Current Record's Letter
    'using [RPTMembers-LetterWithCourseSelections]
    If IsNull(Me!MembInfoID) Then
    MsgBox "Please select a valid record", _
    vbOKOnly, "Error"
    Exit Sub
    End If
    DoCmd.RefreshRecord
    DoCmd.OpenReport "RptMembers-LetterWithCourseSelections", acViewPreview, , "MembInfoID = " & Me!MembInfoID
    End Sub


    And on the Properties of the report, the filter is, for example, MemberInfoID = 95. The "filter on load" is set to No, "Allow Filters" is set to yes.

    Thanks for any help!

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    No idea why the form is printing. Never had this issue.

    I have reports open to preview and user can print with the ribbon button just fine. Since I cannot replicate the issue, would have to work with your db.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    louise is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Apr 2015
    Posts
    112
    Hello, Again,.... still thinking about this issue, which is difficult since I cannot replicate it.
    I am wondering if the focus is perhaps never actually on the report or if the focus is somehow lost when it goes to the filter (which refers back to the form to determine which record to print). Or, if by using the "print" button on the ribbon, the control is somehow lost from the report or stays with the form. Or is the "save record" command diverting the focus?

    Is there a way to put in a line of code that explicitly sets the focus onto the print preview report before the user clicks "print'? I have inserted the code below. (I don't know much coding, so I can't defend this! Any suggestions would be welcome!) Thanks!
    Private Sub butPreviewLetter_Click()
    DoCmd.RunCommand acCmdSaveRecord
    'Print Preview Current Record's Letter
    'using [RPTMembers-LetterWithCourseSelections]
    If IsNull(Me!MembInfoID) Then
    MsgBox "Please select a valid record", _
    vbOKOnly, "Error"
    Exit Sub
    End If
    DoCmd.OpenReport "RptMembers-LetterWithCourseSelections", acViewPreview, , "MembInfoID = " & Me!MembInfoID
    End Sub

  14. #14
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    I'm not sure why the form is printing. How much testing did you do ?
    Can you post a copy of the database with some sample data and instructions to lead us to the "problem area"?

    Have you tried some debugging/debug.prints or stepping through the code?

  15. #15
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    .


    The whole thing is rather simple. After this line of code executes
    Code:
    DoCmd.OpenReport "RptMembers-LetterWithCourseSelections", acViewPreview, , "MembInfoID = " & Me!MembInfoID
    the report will open in print preview and the report will have focus. If the very next thing the user does is click the print button, either from the Ribbon or the QAT, the report will print. If the user clicks on another object before clicking an Access intrinsic print button, the other object will have focus and the other object, as long as it can be printed, will be queued to the printer. So the user needs to be informed of these facts.

    Another approach would be to offer a command button that sends the report straight to the printer. To do this, you would alter your existing code by changing acViewPreview to acViewNormal

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 08-06-2015, 03:26 PM
  2. Replies: 1
    Last Post: 02-21-2015, 11:35 PM
  3. Replies: 5
    Last Post: 07-29-2014, 01:05 PM
  4. Replies: 6
    Last Post: 03-01-2014, 07:07 AM
  5. Replies: 0
    Last Post: 02-22-2011, 05:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums