Query - user chooses fields to be selected

herbtv

New Member
Joined
Jan 28, 2004
Messages
3
Basically, the data I have is in monthly tables and I made the structures identical. But is has over 30 fields and each user might want something different, how do I set up a query to have the user select which fields they want returned? One user might want date, customer name and product, while another might want date, product and price.


Great forums by the way.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
60,886
Office Version
  1. 365
Platform
  1. Windows
Well, here are a few options:

1. Ask the users to design their own query (probably not desired)

2. Create a query with ALL the fileds, and show the users how to go into Design View and show the users how to Select/Deselect the Show option on each field.

3. Create a user form that lists all possible fields next to check boxes. Uers can check off the fields they want and then click on a command button to view the query. You would have to program VBA code behind that command button that will take all the checked fields and create an SQL statement to build the query. If you want to see what SWL code looks like, create a query in Design View and go to SQL View. This is what you want to build.

Option 3 is probably the most desired option, but it is the most complicated, as it requires some VBA code to build SQL statements.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,100
Messages
5,768,095
Members
425,452
Latest member
htay44

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top