Solved

Data Report with data environment

Posted on 2003-10-27
4
320 Views
Last Modified: 2012-06-21
Can you use a parameter or filter so that when someone runs the report (for example: the can select a date) it will only show that data?  And how would you do that?  Can you give me an example?

0
Comment
Question by:sjmmajor
4 Comments
 
LVL 3

Expert Comment

by:gafoorgk
ID: 9628674
yes u can. if u have already defined DataEnvironment and Command objects use the following code as a template

    With deConfiguration
        If (.rscmnAreaList.State = adStateOpen) Then  .rscmnAreaList.Close
       
        With .Commands("cmnAreaList")
            .CommandText = _
                    "SELECT * FROM AREA " & _
                    "WHERE  (AREA_NAME LIKE @AreaName) " & _
                     "ORDER BY AREA_NAME"
            .Parameters("@AreaName").Value = strAreaName
         End With

        .cmnAreaList
    End With


u can also create the same query in design time. then automatically @AreaName will appear in Parameters tab of Command object property dialog box, for which u can set variables in run time.
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 9629118
Or, like this

strSQL = "SELECT * FROM MYTable WHERE AREA_NAME LIKE '" & @AreaName & "' ORDER BY AREA_NAME"  
With DE.rsCmd1
    If  .State=adStateOpen  Then .Close
    .Source = strSQL
    .Open
End With

Also, please read this item as to why not to use Data Enviroment in your code:
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/VB_Databases/Q_20766815.html
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 250 total points
ID: 9630997
0
 

Author Comment

by:sjmmajor
ID: 9678049
Thanks for everyones help!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

808 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