Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Dynamic Column selection for Report in Vb6

Posted on 2014-12-14
13
Medium Priority
?
143 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
13 Comments
 
LVL 101

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 101

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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

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 101

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 101

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 49

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 101

Expert Comment

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

mlmcc
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 2000 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.
Suggested Courses

618 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