Share via

Access 2007 cmdPrint code Problem

Anonymous
2015-01-11T06:24:43+00:00

Upgraded computer from XP to Win 7

I have a db wrote on 2003 Access and when copied over to 2007 Access it will not print. Data light flashes on printer but document will not print and is not left on printer. I have not messed with Access but have been handed this problem and need help.

Private Sub cmdPrint_Click()

On Error GoTo Err_cmdPrint_Click

Dim strDocName As String

Dim strWhere As String

strDocName = "Info"

strWhere = "[ID]=" & Me!ID

DoCmd.OpenReport strDocName, acViewNormal, , strWhere

Exit_cmdPrint_Click:

    Exit Sub

Err_cmdPrint_Click:

    MsgBox Err.Description

    Resume Exit_cmdPrint_Click

End Sub

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

6 answers

Sort by: Most helpful
  1. Anonymous
    2015-01-12T09:56:17+00:00

    Change this line

    DoCmd.OpenReport strDocName, acViewNormal, , strWhere

    To this

    DoCmd.OpenReport strDocName, acViewPreview, , strWhere

    If you can't see it after this change (acViewPreview) open the report in design view and set the PopUp to Yes (in the "All" column of the properties box)

    Then do the right click, etc as I said above 

    Also - just a thought       

    Try change the code to this

    Private Sub cmdPrint_Click()

    DoCmd.OpenReport "info", acViewNormal, "", "ID = Forms!INSERT FORM NAME!ID", acNormal

    End Sub

    Or

    Private Sub cmdPrint_Click()

    DoCmd.OpenReport "info", acViewPreview, "", "ID = Forms!INSERT FORM NAME!ID", acNormal

    End Sub

    of course change INSERT FORM NAME to the real name of your form

    Also "ensure" that your have a control on your form called ID which is linked to a field called ID  and they are both of the same format ??

    I have assumed that you have checked your report design to ensure that it's not formated for another printer and that your printer is working OK (See Gina's post above)

    0 comments No comments
  2. Anonymous
    2015-01-12T08:55:23+00:00

    That code already exists.

    Private Sub cmdPrint_Click()

    On Error GoTo Err_cmdPrint_Click

    Dim strDocName As String

    Dim strWhere As String

    strDocName = "Info"

    strWhere = "[ID]=" & Me!ID

    DoCmd.OpenReport strDocName, acViewNormal, , strWhere

    Exit_cmdPrint_Click:

        Exit Sub

    Err_cmdPrint_Click:

        MsgBox Err.Description

        Resume Exit_cmdPrint_Click

    End Sub

    0 comments No comments
  3. Anonymous
    2015-01-11T17:42:10+00:00

    Sounds like you're sending a blank report to the printer - in this case Acc would send the report, the printer would tell you it has recieved it, nothing would print.

    Try thisChange the code to this

    DoCmd.OpenReport strDocName, acViewPreview, , strWhere

    Does the report open?

    If so, right click and select print

    What happens ?

    0 comments No comments
  4. Anonymous
    2015-01-11T11:36:04+00:00

    Thanks for your reply. Default Printer is selected, Nothing is in printer queue and print all Office docs. Can even print form page in Access. Stumped bad on this one. When Print Report is clicked, the print display pops up saying it is being sent and then disappears.  The receive data light blinks 1 full and a partial flash and then nothing.

    0 comments No comments
  5. Anonymous
    2015-01-11T09:20:09+00:00

    Hmm, do you have a default printer for Windows selected?  Have you tried to print a Word document as a test?  Have you checked the Printer queue to see if there is something *stuck* there?

    0 comments No comments