Dynamic Column selection for Report in Vb6

This is VB6 and SQl Server problem.
I have one table with 10 text fields, 6 numeric fields and 4 date fields. table design is similar like t1, t2, t3, n1, n2, d1, d2, t4, t5, n3, n4, n5, t6, t7, t8, d3, d4, n6, t9. t10. where t =text, n=numeric and d=date field.

filter for record set are one date range (d1, d2) and two combo box for t1 and t2 field.

We display all twenty fields as check box. User select date range (compulsory) and select values of t1 and t2 from combo box (optional) for filter the result set and select any number of check box to display report columns and export this report to excel as xls format with selected column heads as first row.    
Please help me to create dynamic record set  and export the result set to excel as xls.
drdivya78Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mlmccCommented:
WHat have you done thus far?

mlmcc
0
drdivya78Author Commented:
I have prepare query with dynamic value of filters. Now my problem is dynamic adding of column fields and then export filtered data with selected column fields as .xls.
0
mlmccCommented:
Basic code will be something like this

Sequentially check each check box

If chkbox_T1 = vbChecked then
    if SQLWhere  = '' then
         SQLWhere = "TiField = '" & txt_T1 & "'"
    else
         SQLWhere = SQLWhere &  "AND TiField = '" & txt_T1 & "'"
    end if
End if

Repeat for each checkbox

Need code to connect to the database and pass the query

I have code for a project I did years ago that essentially does that.  If you want I can try to find it.

mlmcc
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

drdivya78Author Commented:
Please try to find that code, It confirms that I am preparing dynamic query rightly.

I think I can manage to prepare complete dynamic query with fields and filters but transfer this dynamic result set to xls transfer is problematic. I know how to transfer static query (having predefined field name and type) result set to excel but in dynamic query how we decide field is text, numeric or data type.
0
mlmccCommented:
As I recall I did that by creating another table in the database that was used to store formatting information.

mlmcc
0
drdivya78Author Commented:
I don't understand. Can you please explain though steps for transfer dynamic result set to excel as dynamic query and how we decide field is text, numeric or data type at the time of data transfer.
0
mlmccCommented:
When I find the code, I'll explain how it works.

I have it on a machine I don't use much any more.

mlmcc
0
drdivya78Author Commented:
Please Search and explain.
0
Martin LissOlder than dirtCommented:
I've requested that this question be deleted for the following reason:

The question has either no comments or not enough useful information to be called an "answer".
0
mlmccCommented:
DO you still need an answer.  This fell off my radar.  

mlmcc
0
mlmccCommented:
Here is the code I used

mlmcc
VB-Export-to-Excel.doc
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
drdivya78Author Commented:
fulfill the requirement. Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.