Setting Column Width Programatically

kaspi

Registered User.
Local time
Today, 23:45
Joined
Nov 22, 2000
Messages
60
Hi

I need to programmatically adjust column with on a subform, which is displayed as datasheet (or query in access 2000).

It is very easy to do it from the GUI. However, I cannot work out how to do it.

Unfortunately, I cannot set it up in advance as the form is created on the fly and then displayed as datasheet.

Any idea ..................

kaspi
 
Hi Kaspi
You could try putting this in your code before the form is opened:

DoCmd.OpenForm "F_DataSheet", acDesign, , , , acHidden
Forms![F_DataSheet]![Your-column-name].ColumnWidth = 500
DoCmd.Save acForm, "F_DataSheet"
DoCmd.Close acForm, "F_DataSheet"

I've tried 500 as a width but you'll need to experiment to see what width is shown.

Hope this helps

Helena
 
Hi Helena
Thanks for the suggestion. Unfortunately, in my solution the column name is not static and changes depending on the data I need to display in the subform.
I need to pass the reference to he column as a string something like ' .... columns("column_name").columnWidth
At the moment I manage to get round the problem by changing the default width of the datasheet column (so it matches the width of my data columns) and not deleting the first two fields (which I know that they always be there), setting the width I need and just changing the control source.
Kaspi
 

Users who are viewing this thread

Back
Top Bottom