We help IT Professionals succeed at work.
Get Started

Export data from visible datasheet columns in order displayed

Dale Fye
Dale Fye asked
Last Modified: 2012-05-11
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.

Any ideas?
Watch Question
Most Valuable Expert 2014
This problem has been solved!
Unlock 2 Answers and 8 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE