Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Changing the SQL statement for a Data Environment Command programmatically

Posted on 2004-03-30
4
Medium Priority
?
417 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 1600 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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 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…
Suggested Courses

971 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