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

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
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.
 
Upvote 0

Forum statistics

Threads
1,214,422
Messages
6,119,395
Members
448,891
Latest member
tpierce

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
Back
Top