Results 1 to 8 of 8

Thread: Displaying selected records in data reports

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Posts
    121

    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:
    1. Private Sub DataReport_Initialize()
    2. 'Procedure to connect database
    3. connection
    4.  
    5. strSQL = "SELECT * from tblstudent"
    6. Set rs = New ADODB.Recordset
    7. rs.Open strSQL, cn, adOpenDynamic, adLockOptimistic
    8. Set DataReport1.DataSource = rs
    9. End Sub

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Displaying selected records in data reports

    You would have to modify your code below...

    VB Code:
    1. "SELECT * from tblstudent"

    Provide it a WHERE clause like...

    VB Code:
    1. "SELECT * from tblstudent WHERE Passed = True"
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    Junior Member
    Join Date
    Nov 2004
    Location
    Philippines
    Posts
    27

    Re: Displaying selected records in data reports

    Did you use the refresh method? Try to insert refresh before opening the report.

    VB Code:
    1. DataReport1.refresh

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Posts
    121

    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:
    1. If Datareport1.Sections("Section2").Controls("Text1").Text = "Fail" then
    2. text1.forecolor=vbred
    3. end if

    But it is giving an error Text1 not found.
    Please tell me how to do this?

  5. #5
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Displaying selected records in data reports

    Shouldnt it be something like this?

    VB Code:
    1. If Datareport1.Sections("Section2").Controls("Text1").Text = "Fail" then
    2. Datareport1.Sections("Section2").Controls("Text1").Text.forecolor=vbred
    3. end if
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Posts
    121

    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.

  7. #7
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Displaying selected records in data reports

    I'm just guessing right now but this could be it...

    VB Code:
    1. Datareport1.Sections("Section2").Controls("Text1").Text.[B]font.[/B]forecolor=vbred
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Posts
    121

    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?
    Last edited by c_hillary2000; Aug 11th, 2005 at 01:11 AM.

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