Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


DAO and Data Report 6

Posted on 1999-07-11
Medium Priority
Last Modified: 2013-12-25

I am trying to figure out the Data Report 6 in VB6. I have an app that uses DAO to handle data acquisition and modification. I want to be able to print reports based upon a SQL statement that is determined at runtime and am having no little confusion in figuring out how to pass a SQL statement as the datasource with Data Reports 6. Could someone please tell me what code is necessary to set at runtime and where it should be placed? I know I need the Data environment first and then the data report. I'm assuming the Data Environment is where the SQL is passed, but how?

Question by:kenb030297
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
  • 2
  • 2
  • 2

Expert Comment

ID: 1506406
Just a small hint
I use crystal reports rather than Report writer 6 because i found the report writer with vb6 is very limiting.
goto this site and download the freee version of crystal 6.
it plugs directly inot vb. Whay i do is if i want to create a report dynamically i have my sql set up and when the user click s a button i run my sql statement and populate a temporary table and then open the report. At design time i point the report to the temporary table. So at run time the report displays the inforamtion that the sql statement executed.

Just thought it might help if u do not come write with th report writer


Author Comment

ID: 1506407
Thanks Craig ... I have CR6 but was never able to make head nor tail of how to work it. Your suggestion of a temporary table makes a lot of sense though ... I'll give it a shot. Thanks.

Expert Comment

ID: 1506408
no problem
Ken just install Crustal 6 then go Project ---> Add Activex Manager then u should see Crystal 6 there.

Run Crystal and go thru the wixard of creating a standard report. It will ask u what project u wnat to connect to (being your database) then it auto fetche the tables from that database. then select the table u want to referenece (your TmpTable) than it picks up auto the fields belonging to that table. Then u go thru the standard steps of adding fields onto the report. the wizard does everything for you. Once done u can change the design add fields etc. What is great is that it plugs and the reports are combined into the apps exe file. The previous versions of crystal 4.6(shipped with vb5,vb4) u had to distribute the report files along with the exe file. Which used to get messy.

anyway if that helps .
Also i left out in my comment earlier is that whenever the user runs the dynamic report, i first delete all the records in the temp table before i write into it with the new records as to make sure the data is correct and valid
if this makes any sense :0)


Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


Accepted Solution

ah_sin earned 150 total points
ID: 1506409
I hope my answer won't be too late

I think you are looking for a way to change your sql statement during run-time... if i get your question right, you may want to try this

DE - data environment
comTemp - command object in DE
(set a simple SQL statement in the property window of comTemp)
drTest - data report object
*connect the dataSource property of drTest to DE
*connect the dataMember property of drTest to comTemp
*on drTest... you got the fields you need in the data report (on right places)

set the SQL statement as following in the code

DE.Commands("comTemp").CommandText = _
       "<Your new query statement>"
DE.rscomTemp.Requery      'This line let you to "renew" your

See if this work :)
ah sin

Author Comment

ID: 1506410
Thanks for your help ah_sin,

Your suggestion would work if I had not gone another direction. Since posting this question I changed my entire app to use ADO, decided against the Data Environment and just created several Data Reports which I populate entirely by code. It would be much nicer if MS allowed us to address a control more like they do in VB but with some practice and LOTS of comments, I have managed to locate each control numerically as well as the datafields they are populated by.

Expert Comment

ID: 1506411
so you find ADO easier to use?
I know nothing about ADO :(
I should have try that too

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

704 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