• Select Columns Command (Access 2003)

    Author
    Topic
    #431755

    I have a subform (datasheet) and would like to select a group of columns by clicking a button on the parent form. I’ve looked for a command that allows me to select a column (or group of), but can’t seem to find anything. Does anyone know what command or commands I could use?

    Thanks in advance for any help.
    Drew

    Viewing 1 reply thread
    Author
    Replies
    • #1011251

      Can you tell us what you want to accomplish by selecting columns?

      • #1011266

        The subdatasheet is an intermediate table for data that I get from our PDM system, which is pasted from my clipboard after coping from a system report. After it’s pasted, I select the import button and the data cascades into multiple tables. For now, I don’t need to insert data into some of the tables, so I only select 12 of the 35 columns (script does the rest). It would be nice to have a convenient button to select the columns I’m interested in.

        Thanks,
        Drew

        • #1011268

          I don’t know of any way to use code for selecting columns in a datasheet, but if you already know which columns you need, there should be other ways to fill only the tables you want. Without knowing any details, it is impossible to provide more specific suggestions.

    • #1011276

      If you really need to select columns in a datasheet form (or subform), you can use the Form SelTop, SelLeft, SelHeight, & SelWidth properties for this purpose. The attached database (A2K format) demonstrates how to use these properties to get or set the selected columns (or rows) in a datasheet form. Open one of the sample forms & use the custom toolbar (or custom right-click popup menu) to get or set selected columns. See code module for details. Note that the SetSelection function automatically includes all rows by using the form’s record count (plus one – apparently the column headers count) for SelHeight property. This can be modified as needed. The code also determines if active form is a form or subform, and uses CurrentView property to ensure form is in datasheet view (or error may occur).

      Note: I’m unaware of any way to select non-contiguous columns either “manually” or using VBA. You can select only adjacent columns. Of courses datasheet columns can be rearranged if that is an issue.

      Personally I’ve never had a need to do this in code, when exporting a datasheet I usually export the entire recordset that populates the form or subform.

      HTH

    Viewing 1 reply thread
    Reply To: Select Columns Command (Access 2003)

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

    Your information: