|
-
Oct 5th, 2009, 06:51 AM
#1
Thread Starter
Member
How to open a DataReport by ListView ?
How can I open a DataReport by clicking on ListView Item which loaded from a Recordset ?
-
Oct 6th, 2009, 12:27 PM
#2
Re: How to open a DataReport by ListView ?
-
Oct 7th, 2009, 08:31 AM
#3
Thread Starter
Member
Re: How to open a DataReport by ListView ?
-
Oct 31st, 2009, 01:57 AM
#4
Thread Starter
Member
Re: How to open a DataReport by ListView ?
-
Nov 5th, 2009, 02:51 AM
#5
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
-
Nov 6th, 2009, 05:23 PM
#6
Thread Starter
Member
Re: How to open a DataReport by ListView ?
 Originally Posted by dee-u
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:
'==============================
Private Sub DataGrid_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(DataGrid.Columns(0).Value) & "'"
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
-
Nov 9th, 2009, 12:22 AM
#7
Thread Starter
Member
Re: How to open a DataReport by ListView ?
-
Nov 9th, 2009, 01:59 AM
#8
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
-
Nov 9th, 2009, 04:10 AM
#9
Thread Starter
Member
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:
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.
-
Nov 10th, 2009, 12:47 AM
#10
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.
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|