troubleshooting Question

Access 2010: Creating subreport with VBA with change in Query

Avatar of GNOVAK
GNOVAKFlag for United States of America asked on
Microsoft Access
6 Comments1 Solution1191 ViewsLast Modified:
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.
Two questions:
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?

Jerry
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros