Access VBADiscuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
"If you need to do the same task with a Form [resize columns programatically to display the data currently in the column], it's even easier: Just set all of the ColumnWidth properties to -2. No extra steps are needed."
So in the Form_Open event procedure on my tabular form I'm setting the ColumnWidth property of each control to -2. But the datasheet view does not properly size the columns. What am I missing?
Are you trying to resize the columns on a subform, or form? You mention a tabular form, and datasheets. Datasheets indicates a subform. Perhaps you have this on the wrong form. Open just the subform in design view, and put this code on the SUBform's On Open event.
This is a top level form, not a subform. The columns are filled from a query that changes each time the form is run, so that different columns from the underlying table get displayed on different runs. The user can look at the form in the normal forms view or switch to the datasheet view. In the datasheet view, I'd like the column widths to resize to match the data width.