Link to home
Start Free TrialLog in
Avatar of drdivya78
drdivya78Flag for India

asked on

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.
Avatar of Mike McCracken
Mike McCracken

WHat have you done thus far?

mlmcc
Avatar of drdivya78

ASKER

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.
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
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.
As I recall I did that by creating another table in the database that was used to store formatting information.

mlmcc
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.
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
Please Search and explain.
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".
DO you still need an answer.  This fell off my radar.  

mlmcc
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
fulfill the requirement. Thanks