Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2006
    Posts
    52

    Unanswered: Simple question: how to set Column width in datasheet?

    Hi, I have a form with subforms in datasheet view, I noticed that fields are too wide, I've tried to adjust it manually in design view but didn't work, and in layout view, and even in form view, but it fits temporarily and resets to the previous width after I close the form or change to design view.

    I've searched and found out about ColumnWidth property, I found this article
    ACC2000: How to Use the ColumnWidth Property

    but, just can't find the column width property,, i can only see it with combo box fields, but not in text box fields. Where can I find it? and if it is not possible to find it in property sheet, how can I do that in code?
    I saw an example in the net and accordingly I wrote a code to set a field called 'cost' in a subform called tblBill Subformbut it didn't work

    I put this code in the main form load event (so not in the subform) ..
    Forms![tblBill Subform]![Cost].ColumnWidth = -2

    Any help will be appreciated, thanks

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    The ColumnWidth property does not appear in the Property windows. It can only be addressed using VBA:
    Code:
    Me.MyTextBox.ColumnWidth = 567 ' Always in twips
    Have a nice day!

  3. #3
    Join Date
    Aug 2006
    Posts
    52
    Sinndho
    Thanks a lot, it worked greately,
    I have one question
    Should I put it in form current or form load? it worked in current but which one is the most suitable

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    I would place it in the Form_Load event handler. In Form_Current it will be executed repeatedly, as the Current event is triggered every time you select another record, which for a form in datasheet view occurs every time you select another row.
    Have a nice day!

  5. #5
    Join Date
    Aug 2006
    Posts
    52
    sorry for the late reply
    Sinnhdo, I highly appreciate your help
    You are a book of experience and I learned a lot from you, really many thanks

  6. #6
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •