vbams-accesscrashsubreport

Subreport causes application crash - VBA -MS Access


I have a report and within it a subreport.

After opening the report once, it's a matter of time until the application crashes.

I tried running the app without the subreport - that didn't crash.

With the subreport - crashed.

I tried simplifying the link / binding between report and subreport by setting the record source of the parent to a simple temporary local table, and having the bound column be it's Primary Key.

Yet nothing helped.

I tried roaming the Internet for any known issue - yet I was still left with my crash case.

In Microsoft documentation I got the idea to look carefully at the linking fields and understanding them better.

Elsewhere I saw general advice to Minimize the use of nested subforms/subreports (they chew through memory).

I double checked the RecordSources of both Parent and Child reports, yet the application keeps crashing when testing.

It doesn't crash on a specific line, each time it crashes elsewhere in code - giving me a very straight forward understanding that after opening this report with it's subreport - the application get's corrupted. After that the application crashes at random use cases, but it eventually crashes every time!

I'd be glad to get help with this, please

Edit: I tried switching the subreport with a newly created unbound empty report - even then it crashes. And still when I remove the subreport - no crash!

Edit 2: I recreated the Parent report from scratch too and still crashed.

Though I did notice that I could work around the "subreport problem": When I commented out parts of the code in the report module, yet left the subreport untouched - I was suprised to see that application didn't crash.


Solution

  • This answer is not strictly scientific, but it suits the situation faced in the question - which was also very unclear (what's causing the crash?!)

    In my case - after noticing that removing code from the report module helped that the application won't crash - I carefully returned the code bit by bit until I reached line that re-caused the crash. In my case there it was a trivial line of code:

    logopic.picture = inpic
    

    (I have this same line of code in so many reports...! - and works no problem!)

    For this very specific case: I moved the line of code from Report_Open to PageHeader_Format

    And that made the difference. This said - is on top of what I mentioned earlier - that I modified the RecordSource of the report to a simple local table instead of a complex query.

    Still uncertain of the stability of this solution, because it makes no sense.

    The only sense that I could see in this whole thing - that my accdb file was somehow reaching it's limit for some reason when trying to open this report of mine, and if I slightly make it easier for him/it that might do it - and so it did.