Discussion Locked

Creating Reports in Visual Basic

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
i am creating reports in VB using the data environment. I have 25 customers in a table with l need to print invoice to. I have created a report, that should print a invoice to one customer. But what happens when l run the report is that the report prints all the customers in the database. When l just want to print a indiviual record. How can l do this. I have also created a form that displays all the records using the movenext method. So when l am a customer record, l should be able to print the invoice for that customer.

5 replies

by seagull data services

You need to set your report's recordsource to point to the specific customer. Assuming your Customer has a unique identifier (call it CustID) and your table has only one record per customer you would set your report's recordsource to

"select from where .CustID=;"

This will provide a single record for the report.
Hope this helps
John

by bwmulanda

You will need to make use of parameters in your data environment.

Firstly, change the recordsource of your command to be an sql statement with a parameter.

For example:
Select from

where CustID = myid

Myid becomes yourparameter. Set the other properties of this parameter through the parameters tab.

Secondly, in your report calling procedure, you will have to pass the customer id value to the command. You have to ensure the associated recordset for this commandis closed before doing this.

For example:
if datenv.rscustomers.state = adstateopen then
datenv.rscustomers.close
end if
datenv.customers txtid.text
myreport.show

Alternatively, you may simply dynamically generate the commandtext in code.

For example:
Dim strSQL as string

strSQL = "select from

where custid = " & txtid.text

'Ensure that associated recordset is closed
........
'Set the command text
datenv.customers.commandtext = strSQL

This discussion is closed to new replies.