OutputTo acreport crashes access when filtered

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • James Bowyer
    New Member
    • Nov 2010
    • 94

    OutputTo acreport crashes access when filtered

    I need to only print one page of a report, not the whole thing, but do so automatically. Annoyingly, I can't seem to get it to work!

    This:

    Code:
    DoCmd.OutputTo acOutputReport, "rptmouldcurrent", acFormatPDF, "C:\Temp\Test.pdf", False
    works ok, but prints out all reports, not just the one I want.

    So, I tired this:
    Code:
    DoCmd.OpenReport "rptmouldcurrent", acViewPreview, , "[Mouldref]='" & Me.CboxMould & "'", acWindowNormal
    
    DoCmd.OutputTo acOutputReport, "rptmouldcurrent", acFormatPDF, "C:\Temp\Test.pdf", False
    
    DoCmd.Close acReport, "rptmouldcurrent"
    But this causes Access to crash catastrophicall y.
    Any ideas why its happy to deal with lots of reports, but just one flummoxes it?
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    at which line is it crashing?
    place a STOP command at the begining of the procedure, once the code enters debug mode, [F8] to step thru the code till error.

    >>Edit>> Also move your Where String out of the function and build it first. This way we can troubleshoot it.
    Code:
    Dim strSQL As String
    strSQL = "[Mouldref]='" & Me.CboxMould & "'"
    DoCmd.OpenReport ReportName:="rptmouldcurrent", View:=acViewPreview, WhereCondition:=strSQL, WindowMode:=acWindowNormal
    I don't think you'll need the "[]"
    Last edited by zmbd; Jan 14 '14, 04:29 PM.

    Comment

    • James Bowyer
      New Member
      • Nov 2010
      • 94

      #3
      I'm not sure at which point the code crashes, it doesn't enter debug mode, Access stops working, and needs to be shutdown.

      It would be much simpler to sort if it crashed normally!

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        that's fine

        please do as I suggested with the stop command, this forces debug mode at that point.

        I cannot help you, nor can anyone else, if you ignore our requests.

        Comment

        Working...