Solved

Changing the SQL statement for a Data Environment Command programmatically

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Use Multiple Forms 4 57
Updates not working for MS Windows 7 12 164
Macro Excel - Multiple If conditions 2 71
Sub or Function is not defined 6 25
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…
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…
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…
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…

813 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

12 Experts available now in Live!

Get 1:1 Help Now