The answer is in dblist1.SelectedItem --- this gives you the index My code for an EXAMPLE!!!!
Private Sub DataList1_Click()
Dim strQuery As String
strQuery = "Select * FROM Products WHERE SupplierID = " & _
DataList1.BoundText
With adoProducts
.RecordSource = strQuery
.Refresh
End With
With DataGrid1
.ClearFields
.ReBind
End With
''move adoProducts.Recordset to the same number as the index of the datalist
adoProducts.Recordset.Move (DataList1.SelectedItem - 1) '' minus 1 as first entry in recordset is zero
End Sub
Can you use a datalist component vice a databaselist one? Or is that simply the name you gave the datalist component?
Make sure you actually SELECT an item in the datalist component, otherwise your XXlist1.selectedItem WILL be NULL.
Send my your section of code and I'll test. (Or, take mine (using a datalist component (datalist1) and a datagrid component (DataGrid1) and an ADODC component (adoProducts), connect them to a database (a great example is located in the msdn library showing how to use these components), and test it yourself). If you can't figure it out, I'll send you my entire (small) VB project so you can see how I set up each component).
Private Sub DataList1_Click()
Dim strQuery As String
strQuery = "Select * FROM Products WHERE SupplierID = " DataList1.BoundText
With adoProducts
.RecordSource = strQuery
.Refresh
End With
With DataGrid1
.ClearFields
.ReBind
End With
''move adoProducts.Recordset to the same number as the index of the datalist
adoProducts.Recordset.Move (clng(DataList1.SelectedItem) - 1) '' minus 1 as first entry in recordset is zero
End Sub
Last edited by firoz.raj; Aug 30th, 2012 at 01:36 PM.