views:

30

answers:

2

I would like to create an Access report in which the record source is created via ADO code and then set as the record source for the report when the report is run. The problem I am running into is how to add fields to the report since the recordset is bound to the report at run-time and not design time. Is there way I can manually add the field and make sure the field name matches what will be provided in the recordset field collection? Thank you.

+1  A: 

Several ways to do it, but all of them have their issues. create-dynamic report using vba Other questions have found the folley in working in design mode programatically.

Jeff O
+2  A: 

The standard solution to this problem is to add all your fields in design view, up to the max available, and hide all of them, and show only the ones you need. Michael Kaplan explained that when he designed the Access Replication Conflict Resolver, this is the approach he used, precisely because adding controls at runtime quickly uses the lifetime limit on the number of controls on a form (700+, but I can't recall the exact number).

It's also just a bad idea, as @Jeff O says, to do design changes at runtime. For one, it means you can never distribute an MDE.

David-W-Fenton