Data Environment / Data Report


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Data Environment / Data Report

  1. #1
    Duane Snelling Guest

    Data Environment / Data Report


    Hi all,

    It been awhile since I used the Data Environment. One quick question.

    How would I get the data report to print only one entry in a database?

    I know I could use the SQL in the Command1 object, but I need to have the
    user decide on what to view. I guess what I am asking is, how would I use
    a custom SQL statement using varibles in code rather than using the command
    properities?

    Thanks for your help.

    Duane...

  2. #2
    Russ Guest

    Re: Data Environment / Data Report


    "Duane Snelling" <duane.snelling@sympatico.ca> wrote:
    >
    >Hi all,
    >
    >It been awhile since I used the Data Environment. One quick question.
    >
    >How would I get the data report to print only one entry in a database?
    >
    >I know I could use the SQL in the Command1 object, but I need to have the
    >user decide on what to view. I guess what I am asking is, how would I use
    >a custom SQL statement using varibles in code rather than using the command
    >properities?
    >
    >Thanks for your help.
    >
    >Duane...


    Duane,
    You can do this by using a parameter in the sql of your command object.
    First, in the DataEnvironment, edit your command and add your parameter(s)
    in the where clause. You can do this by right-cliking on the command object
    and selecting properties. Select "SQL Statement", and either type your sql
    in the textbox or use the SQL Builder to create it. Either way, it should
    look something like-

    SELECT *
    FROM tblMyTable
    WHERE MyField = prmMyParam


    Next, you can pass the value into the parameter before you open the report
    by doing something like this-

    Private Sub cmdOpenReport_Click()
    Dim prm As ADODB.Parameter

    Load de
    With de

    If .rsMyCommand.State <> 0 Then
    .rsMyCommand.Close
    End If

    Set prm = .Commands("cmdMyCommand").Parameters("prmMyParam")

    End With

    prm.Value = "Something"

    rptMyReport.Refresh

    rptMyReport.Show vbModal

    Unload rptMyReport

    Set prmMyParam = Nothing
    End Sub

    HTH,
    -Russ.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center