Setting query column widths from VBA

Nick Booth

New member
Local time
Today, 17:32
Joined
Jun 25, 2000
Messages
5
I have written code behind a form to create acrosstab query and run it. I want the code to set all the column widths to best fit. Can it be done?
I have used SendKeys to select the columns and DoCmd to open the format columnwidth dialog but the dialog won't accept SendKeys input to 'click' the best fit button. I tried sending 4 Tabs and a return but the dialog didn't even respond inappropriately.
 
When you open a query by DoCmd.OpenQuery it performs this query just as if you opened it from the database-window.
That's why you can format the output of a DoCmd.OpenQuery-command by formatting the output when opening from the database-window. There you select a certain column and set it to the appropriate width (and save query afterwards).

Hope you can work through.
 
Thanks MHM.
In fact I knew this already but want the column widths to be set from code to make life easier for some of my more technophobe users.
 

Users who are viewing this thread

Back
Top Bottom