Access 2010: Creating subreport with VBA with change in Query
I'm using Access 2010 and giving the user a method of selecting records to view AND the fields to view.
I create a query on the fly, always naming it the same. The field names can change as can the where clause. I handle all this through VBA quite smoothly.
Now the tough part - I wish to display the results in a data view subform. This will allow the user to size and sort.
1) When I set up the subreport and tell it to base it off of a query, it uses the fields that exist AT THE TIME of creation. My routine changes the query and the fields. I would like the subreport to use the same named query but the fields have changed. I'm thinking I can place fields in the detail section of the subreport on the fly, requery and everything should be good.
Does anyone know how to do something like this? I'm not talking about new records - that's handled by by where clause in the query and it's working great...as a query. Problem is that the fields have changed as well.
2) is there a way for the autosize to use column headers as well as data to autosize the columns?