Results 1 to 4 of 4

Thread: generate a report based on SQL statement

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2006
    Posts
    977

    generate a report based on SQL statement

    Hi
    I am using the data report designer.I want that when the user clicks on a command button called "Generate report",to be prompted by an inputbox asking him to enter the CustomerID,if he enters a non null string and press on ok,to generate a report based on the customerID entered by the user.

    the syntax of the SQL command:
    Select * from Customer where customerID='the value entered in the inputbox'
    the report must be generated based on the above SQL statement

    how can i do it?

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: generate a report based on SQL statement

    Depending on the db

    1) make a query/view that takes parameters
    2) write the sql to a string (selection of main fields) then add in the where clause as appropiate.
    3) other ways

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2006
    Posts
    977

    Re: generate a report based on SQL statement

    Hi Ecniv
    i am using SQL server 2000,my problem is that how can I tell my program that the source of Data is the SQL statement,
    thanks

  4. #4
    Addicted Member
    Join Date
    Jun 2005
    Posts
    169

    Re: generate a report based on SQL statement

    Hi,
    If you make the SQL statement as a stored procedure, set the report recordsource to this and design your report. Then, before you display teh report, filter the contents using the CustomerID. e.g.
    if your reportdocument is called RptToView and you Stored Procedure is called f_rptMyBatches, then, the recordselection formula will look like:

    RptToView.DataDefinition.RecordSelectionFormula = "{f_rptMyBatches;1.CustomerID} = " & YourCustomerIDHere

    where CustomerID is the name of the field.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width