PDA

Click to See Complete Forum and Search --> : generate a report based on SQL statement


engnouna
Jun 19th, 2006, 06:00 AM
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?

Ecniv
Jun 19th, 2006, 06:43 AM
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 ;)

engnouna
Jun 19th, 2006, 07:21 AM
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

dec_obrien
Jun 19th, 2006, 07:33 AM
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.