• build combo box programmatically (97 sr2)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » build combo box programmatically (97 sr2)

    Author
    Topic
    #369787

    Trying to build a form on-the-fly based on information stored in a control table. For the combo box, I want to hide the first column and display the second column. If I were creating the combo manually, I would enter the following into the Column widths Property: 0″;2″;3″

    Here is a code snippet where the combo is created:

    With frm.Controls(“combo” & intComboCounter)
    .ControlSource = rst!FieldName
    .RowSource = rst!RowSource
    .ColumnCount = rst!ColumnCount
    .ColumnWidths = rst!ColumnWidths ‘********* here ****
    .ColumnHidden = False
    .ColumnWidth = rst!fieldwidth
    .ListWidth = 3 * .ColumnWidth
    .ColumnOrder = intCounter
    End With

    The rst!ColumnWidths field is Text, and I’ve tried the following permutations:
    0″;2″;3″
    0;1500;1500 (valid .ColumnWidth values are in this range!)
    0,2,3
    0;2;3
    etc

    In all cases, the item displayed is column #1 even though I’ve entered a zero for the first column width. What do I enter into the ColumnWidths field to hide the first column of the combo?

    Thanks.

    Viewing 1 reply thread
    Author
    Replies
    • #583106

      Is rst!ColumnCount equal to 3?

    • #583135

      If you are using the inches as unit of measurement the ColumnWidths setting should read like this:

      Me.Combo2.ColumnWidths = "0 in;2 in;3 in" 

      HTH

      • #583161

        thanks Mark. that worked. also turns out that measurements in Twips works, too (0;1400;2880)

        However, the real culprit in this case was database corruption. Your suggestion did not work initially. Then I repaired and compacted the database, and it magically worked properly. Gotta remember those details when thing go strange…

        Thanks

    Viewing 1 reply thread
    Reply To: build combo box programmatically (97 sr2)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: