Subreport resize bug in Access 2013

I had a working report in Access 2000, 2002, and 2003 (at least).  I just tried running it in Access 2013 and it hangs indefinitely.  After several hours of troubleshooting, I managed to isolate and reliably reproduce the error.  I offer the following Minimal, Complete, and Verifiable Example of the problem. 

I dare say this is a bug in the Access engine.  I would love to be proved wrong.

To reproduce, open a new blank database in Access 2013.  It can be any format, 2000 mdb; 2002-2003 mdb; or 2007-2013 accdb.  Then copy and paste the code below into a new standard code module.  Run the procedure to reproduce the problem:

Sub ShowcaseSubreportResizeBug()
    'Create a simple table to act as Recordsource
    CurrentDb.Execute "SELECT 1 AS ID INTO Mcve"
    CurrentDb.Execute "INSERT INTO Mcve(ID) Values (2)"

    'Create a subreport bound to our simple table
    Dim SubRpt As Report, SRName As String
    Set SubRpt = CreateReport
    SubRpt.RecordSource = "SELECT TOP 2 * FROM Mcve"
    SRName = SubRpt.Name
    DoCmd.Save , SRName
    DoCmd.Close acReport, SRName
    Set SubRpt = Nothing

    'Create the main report...
    Dim Rpt As Report, RptName As String, SRCtlName As String
    Set Rpt = CreateReport
    RptName = Rpt.Name
    '...add the subreport control...
    With CreateReportControl(RptName, acSubform, acDetail)
        .SourceObject = "Report." & SRName
        SRCtlName = .Name
    End With
    '...change the size of the subreport control in code...
    Rpt.Section(acDetail).OnFormat = "[Event Procedure]"
    Rpt.HasModule = True
    Rpt.Module.InsertLines Rpt.Module.CountOfLines, vbCrLf & _
                                                    "Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)" & vbCrLf & _
                                                    "    Me.Child0.Height = 0.1" & vbCrLf & _
                                                    "End Sub"
    '...save and close the main report
    DoCmd.Save , RptName
    DoCmd.Close acReport, RptName
    Set Rpt = Nothing
    
    'Preview the newly created report (this will cause msaccess.exe to stop responding)
    MsgBox "Click OK to observe MS Access hanging when trying to open report, '" & RptName & "'."
    DoCmd.OpenReport RptName, acViewPreview
End Sub

September 11th, 2015 5:10pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics