Solved

Dynamic Column selection for Report in Vb6

Posted on 2014-12-14
13
128 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
 

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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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 45

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article will show, step by step, how to integrate R code into a R Sweave document
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now