Results 1 to 10 of 10

Thread: How to open a DataReport by ListView ?

  1. #1

    Thread Starter
    Member
    Join Date
    May 2009
    Posts
    55

    How to open a DataReport by ListView ?

    How can I open a DataReport by clicking on ListView Item which loaded from a Recordset ?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How to open a DataReport by ListView ?

    Moved To Reporting

  3. #3

    Thread Starter
    Member
    Join Date
    May 2009
    Posts
    55

    Re: How to open a DataReport by ListView ?

    I am waiting a solution.

  4. #4

    Thread Starter
    Member
    Join Date
    May 2009
    Posts
    55

    Re: How to open a DataReport by ListView ?

    I still wait.

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

    Re: How to open a DataReport by ListView ?

    Something like this.
    Code:
    Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
        If Not ListView1.SelectedItem Is Nothing Then
            DataReport1.Show 1
        End If
    End Sub
    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
    Member
    Join Date
    May 2009
    Posts
    55

    Re: How to open a DataReport by ListView ?

    Quote Originally Posted by dee-u View Post
    Something like this.
    Code:
    Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
        If Not ListView1.SelectedItem Is Nothing Then
            DataReport1.Show 1
        End If
    End Sub
    Yes, thank you.
    But I need to return a value from ListView to open DataReport by it.

    I use this code with DataGrid for same purpose:

    VB Code:
    1. '==============================
    2. Private Sub DataGrid_DblClick()
    3. '==============================
    4.  
    5.   On Error GoTo Null_Click
    6.  
    7.   Dim RSReport As ADODB.Recordset
    8.   Set RSReport = New ADODB.Recordset
    9.      
    10.   Dim SQL As String
    11.    
    12.    SQL = "SELECT * FROM mytable "
    13.    SQL = SQL & " WHERE id LIKE '" & Trim(DataGrid.Columns(0).Value) & "'"
    14.    SQL = SQL & " ORDER BY id ASC;"
    15.  
    16.   If RSReport.State = adStateOpen Then RSReport.Close
    17.   RSReport.Open SQL, DB, adOpenStatic, adLockOptimistic
    18.  
    19.   If RSReport.RecordCount > 0 Then
    20.  
    21.      Set DataReport1.DataSource = RSReport
    22.      DataReport1.WindowState = 2        
    23.      DataReport1.Orientation = rptOrientPortrait    
    24.      DataReport1.Show , Me
    25.  
    26.   Else
    27.      MsgBox " There is no results. "
    28.  
    29.   End If
    30.  
    31.   SQL = ""
    32.  
    33. Null_Click:
    34.   Exit Sub
    35.  
    36. End Sub

  7. #7

    Thread Starter
    Member
    Join Date
    May 2009
    Posts
    55

    Re: How to open a DataReport by ListView ?

    I am looking for someting like this:

    http://www.vbforums.com/showthread.php?t=532391

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

    Re: How to open a DataReport by ListView ?

    You've got the code already, you just have to modify it with something like this.

    Code:
    Private Sub listview1_DblClick()
        On Error GoTo Null_Click
      
        Dim RSReport As ADODB.Recordset
        Set RSReport = New ADODB.Recordset
          
        Dim SQL As String
        
        SQL = "SELECT * FROM mytable "
        SQL = SQL & " WHERE id LIKE '" & Trim(listview1.SelectedItem.Text) & "'"
        SQL = SQL & " ORDER BY id ASC;"
      
        If RSReport.State = adStateOpen Then RSReport.Close
        RSReport.Open SQL, DB, adOpenStatic, adLockOptimistic
    
        If RSReport.RecordCount > 0 Then
      
            Set DataReport1.DataSource = RSReport
            DataReport1.WindowState = 2
            DataReport1.Orientation = rptOrientPortrait
            DataReport1.Show , Me
    
        Else
            MsgBox " There is no results. "
      
        End If
      
        SQL = ""
    
    Null_Click:
        Exit Sub
    End Sub
    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

  9. #9

    Thread Starter
    Member
    Join Date
    May 2009
    Posts
    55

    Re: How to open a DataReport by ListView ?

    Thank you.
    But I need to get the first value (first column) from selected row in ListView, it's an ID number.
    I got it with DataGrid by:
    VB Code:
    1. DataGrid.Columns(0).Value
    I just want to apply the same way but with ListView.
    Last edited by alMubarmij; Nov 9th, 2009 at 05:17 AM.

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

    Re: How to open a DataReport by ListView ?

    .SelectedItem.Text should give you that, have you tried it? .SelectedItem is the selected row and the .Text is the first column.
    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

Tags for this Thread

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