Solved

Dynamic Column selection for Report in Vb6

Posted on 2014-12-14
13
132 Views
Last Modified: 2015-01-08
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.
0
Comment
Question by:drdivya78
  • 6
  • 5
13 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 40499649
WHat have you done thus far?

mlmcc
0
 

Author Comment

by:drdivya78
ID: 40500935
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
 
LVL 100

Expert Comment

by:mlmcc
ID: 40501904
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:drdivya78
ID: 40502049
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
 
LVL 100

Expert Comment

by:mlmcc
ID: 40502658
As I recall I did that by creating another table in the database that was used to store formatting information.

mlmcc
0
 

Author Comment

by:drdivya78
ID: 40502976
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
 
LVL 100

Expert Comment

by:mlmcc
ID: 40503212
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
 

Author Comment

by:drdivya78
ID: 40504885
Please Search and explain.
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40539502
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
 
LVL 100

Expert Comment

by:mlmcc
ID: 40539468
DO you still need an answer.  This fell off my radar.  

mlmcc
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 40539495
Here is the code I used

mlmcc
VB-Export-to-Excel.doc
0
 

Author Closing Comment

by:drdivya78
ID: 40539503
fulfill the requirement. Thanks
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question