Results 1 to 4 of 4
  1. #1
    MatthewR is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2015
    Posts
    118

    "DoCmd.RunCommand acCmdPrint" Makes Preview Go Blank

    Good afternoon. I have a command button that opens a report in print preview mode, and then opens the print dialog. Here's the code:

    Code:
    DoCmd.OpenReport "rptActivity", acViewPreview, , "ClientID=" & IDNumber
    DoCmd.SelectObject acReport, "rptActivity"
    DoCmd.RunCommand acCmdPrint
    The problem is, when it runs the last line of code (the one that makes the print dialog pop up), the Preview goes blank- evertything disappears. So, the user might think that they are printing nothing.

    In fact, when you follow through with the print, it works just fine. And after the print dialog closes, the Preview goes back to normal.

    But I don't want to confuse the user by having the Preview look blank when the dialog is open. Why is it doing this, and how can I fix it? Thanks.

    Matt

  2. #2
    nrgins's Avatar
    nrgins is offline some guy
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    62
    Not sure that you can fix it. Seems to be how Access functions.

    Have you considered doing a DoCmd.PrintOut instead? Or do you need the dialog box?

    P.S. The SelectObject line isn't necessary. The report will be the current object immediately after it's opened.

  3. #3
    MatthewR is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2015
    Posts
    118
    Okay, thanks. Yeah, I do want the dialog box. But I've figured out a solution. I made the command button maximize the form before printing the report, so that it obscures the report preview (minimizing or hiding the preview doesn't seem to work).

    Ideally, I'd want the users to see a preview- but I'd rather they not see the preview at all than get confused by seeing a blank preview.

  4. #4
    nrgins's Avatar
    nrgins is offline some guy
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    62
    Cool. Glad you found a workaround!

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

Similar Threads

  1. Replies: 1
    Last Post: 09-07-2015, 08:00 AM
  2. Replies: 10
    Last Post: 09-03-2015, 01:31 PM
  3. Replies: 3
    Last Post: 01-27-2015, 12:25 PM
  4. Replies: 3
    Last Post: 07-19-2012, 06:22 AM
  5. Replies: 1
    Last Post: 09-05-2008, 12:07 PM

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