Displaying selected records in data reports
Hi all
I am using data reports with out data environment.Here i am displaying the report using a table. But i am not able to display the selected records.
For e.g. A report displays Student id, Name and result.
But i want to display the results of only the passed students.can anyone please tell me How i do this?
I have used the following code:
VB Code:
Private Sub DataReport_Initialize()
'Procedure to connect database
connection
strSQL = "SELECT * from tblstudent"
Set rs = New ADODB.Recordset
rs.Open strSQL, cn, adOpenDynamic, adLockOptimistic
Set DataReport1.DataSource = rs
End Sub
Re: Displaying selected records in data reports
You would have to modify your code below...
VB Code:
"SELECT * from tblstudent"
Provide it a WHERE clause like...
VB Code:
"SELECT * from tblstudent WHERE Passed = True"
Re: Displaying selected records in data reports
Did you use the refresh method? Try to insert refresh before opening the report.
Re: Displaying selected records in data reports
Thanks for the reply.
It is working fine. I have to design one more report, where i have to display the results of all the students and highlight the records with the results fail in red.
I tried to do this using an if statement
VB Code:
If Datareport1.Sections("Section2").Controls("Text1").Text = "Fail" then
text1.forecolor=vbred
end if
But it is giving an error Text1 not found.
Please tell me how to do this?
Re: Displaying selected records in data reports
Shouldnt it be something like this?
VB Code:
If Datareport1.Sections("Section2").Controls("Text1").Text = "Fail" then
Datareport1.Sections("Section2").Controls("Text1").Text.forecolor=vbred
end if
Re: Displaying selected records in data reports
Thanks for the reply.
I tried with this code.But it is still giving me the same error.
Re: Displaying selected records in data reports
I'm just guessing right now but this could be it...
VB Code:
Datareport1.Sections("Section2").Controls("Text1").Text.[B]font.[/B]forecolor=vbred
Re: Displaying selected records in data reports
Thanks for the reply.
It is still giving me the same error. we can use the same code for lables to change their caption,Font fore color etc.
But the same not working for a text box.I don't know why conditional statement is not working in the report.
Can I assign two tables for the same report using data source method?