I've got a couple of forms which display data in subforms which display query results in a datasheet format.
I don't normally like datasheets, but my client has about a dozen people using this particular application, and each of them is only interested is about 10 of the 30 fields in this table. So they wanted a way for their users to hide and rearrange the columns and the datasheet seemed like the most appropriate option.
Now they want their users to be able to export the filtered recordset that is currently displayed in the datasheet to an Excel spreadsheet, but they only want to display the fields that are visible in the subform, and they want them displayed in the column order the user has defined by dragging the columns.
So, I'm looking for a way to build a dynamic SQL string which selects only those fields that are displayed and in the order they are displayed. I know I can use the columnHidden property of the controls collection to determine whether the column is visible or not. But I've been unable to identify the appropriate property to loop through the collection and identify the sequence that they are displayed in, so I can build the SQL string.