none
ctrl.ColumnWidth = -2 RRS feed

  • Question

  • Thanks for taking the time to read my question.

    I'm using ctrl.ColumnWidth = -2 to size the width of my datasheet form column widths. It seems that this is based on the column title and not the widest value in the column data.

    Is this how it's supposed to work? I was expecting it to work more like Excel where the max width is equal to the widest value in the entire column.

    Thanks,
    Brad

    Wednesday, October 18, 2017 3:55 PM

Answers

  • Hi,

    Thank you for the quick reply. That is what I understood also. My datasheet is only returning one record so it is always visible.

    The datasheet is a subform... not sure if that makes a difference.

    I have implemented this:

    ctrl.ColumnWidth = -2
    If ctrl.ColumnWidth < 1000 Then
        ctrl.ColumnWidth = 1000
    End If

    This makes things work ok as long as the value is less/equal to than $9999.99

    Thanks,
    Brad

    • Marked as answer by mbrad Wednesday, October 18, 2017 4:29 PM
    Wednesday, October 18, 2017 4:29 PM

All replies

  • Hi Brad,

    Not sure what to tell you, but the Help file says -2 sizes the column width to the "visible" text. To me, it means the columns will auto-size to the widest data currently displayed on the screen. It's possible when you scroll down, you might see data in the field wider than the size of the column.

    Hope it makes sense...

    Wednesday, October 18, 2017 4:17 PM
  • Hi,

    Thank you for the quick reply. That is what I understood also. My datasheet is only returning one record so it is always visible.

    The datasheet is a subform... not sure if that makes a difference.

    I have implemented this:

    ctrl.ColumnWidth = -2
    If ctrl.ColumnWidth < 1000 Then
        ctrl.ColumnWidth = 1000
    End If

    This makes things work ok as long as the value is less/equal to than $9999.99

    Thanks,
    Brad

    • Marked as answer by mbrad Wednesday, October 18, 2017 4:29 PM
    Wednesday, October 18, 2017 4:29 PM
  • Hi Brad,

    Glad to hear you found a solution. Good luck with your project.

    Wednesday, October 18, 2017 4:32 PM