Solved

Changing the SQL statement for a Data Environment Command programmatically

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

743 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

10 Experts available now in Live!

Get 1:1 Help Now