Solved

Changing the SQL statement for a Data Environment Command programmatically

Posted on 2004-03-30
4
410 Views
Last Modified: 2013-12-25
I am using a Data Report to display data from an Access Database.  The Data Report gets its data from a Data Environment Command object.
I need to customize which records are viewed, based on which records the user is viewing.  I would like to change the SQL statment for the Command object, before using the Data Report to view the data from the Command object.  First, i'm not sure how to reference the SQL statement other than dataEnvironment.Commands.Item(n).CommandText = strSQL which works, but it is ugly.
But the main problem is that after I have changed this value, the report no longer recognizes the Command object.  it says "The Microsoft Jet database engine cannot find the input table or query 'commandName'. Make sure it exists and that its name is spelled correctly".
The worst part is, that when I step through the commands in debug mode, it works, once.  The second time it gives me the same error message, if I haven't restarted the application in between.

Any suggestions? It seems like a VB bug to me.  If it can't be changed, can I avoid using the Data Environment altogether and have the reports refer to an ADO data control instead, and how would I do that?
0
Comment
Question by:leonjanzen
4 Comments
 
LVL 18

Accepted Solution

by:
Sethi earned 400 total points
ID: 10719846
You can not change the controls on the report dynamically becuase each control is bound to its data source at design time. Your changing it this way results in the error becuase the already bound controls are not able to see their data source.

You can however have unbound control on the report and use Recordset as data source at runtime to bound controls. Having said that, I feel that Crystal Reports will be a better solution for you rather than Data Reports as Data Reports is a very very basic reporting tool.
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 10758928
Agree with Sethi.

Forget Data Reports, DE and ADODC go directly to using ADO and Crystal Reports.  Data Reports, DE and ADO are useless in any production quality applications.  You will run into many issues with them.  

Let us know if you need help in switching,

Leon
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

820 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