Solved

Changing the SQL statement for a Data Environment Command programmatically

Posted on 2004-03-30
4
412 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
[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
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month3 days, 21 hours left to enroll

630 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