Share via

Can't change Column Width in code in Access datasheet

Mark Liquorman 16 Reputation points
2022-03-08T20:05:38.05+00:00

I thought I've done this before, but it doesn't seem to work now. I'm trying in code to reset the widths of columns in an Access datasheet (based on a query). I can set the .ColumnOrder and the .ColumnHidden properties just fine, but any change I make to the .ColumnWidth property is just ignored (setting in twips). I've tried in both the Form Load and Open events. With the datasheet open, I can even set the .ColumnOrder and .ColumnHidden properties for a column from the Immediate Window, but not the .ColumnWidth.

What would be preventing me from doing this?

Developer technologies | Visual Basic for Applications
0 comments No comments

1 answer

Sort by: Most helpful
  1. Mark Liquorman 16 Reputation points
    2022-03-08T20:54:37.54+00:00

    Well, I figured out my problem! I didn't realize it, but all the controls on the form where set to .Visible=False! Only Datasheet mode was allowed, so never noticed this. This didn't affect the columns from displaying on the datasheet, but apparently it prevented the columnwidths from being changed. I made them visible and now I can change the columnwidths. Go figure! (There's a few hours of my life I can't get back!)

    Was this answer helpful?

    2 people found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.