GOod afternoon,
I am new to VB6 however relatively experienced in VBA.
I am attempting to load information into a ListView control via an Access DB. I have placed the following code into the form_load event.
However I receive an error on the highlighted line: "Image List must be initialized before it can be used".
When I initially added the listview, I right clicked on the control and selected properties. I have the view set as '3 - lvwReport'. I set up my 5 columns by going to the Column Headers tab and entering each. However when I go to Image Lists, all the drop downs show '<none>'
Thoughts?
Code:Private Sub Form_Load() Dim MyConn As ADODB.Connection Set MyConn = New ADODB.Connection MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=H:\Business Intelligence\VB6\Database9.mdb;" MyConn.Open Dim strSQL As String 'our query string Dim oRS As ADODB.Recordset 'our recordset object Dim lvwItem As ListItem 'this is necessary to directly reference the ListView control Set oRS = New ADODB.Recordset 'change this SQL as appropriate for your needs strSQL = "SELECT Date_Entered, Loan_Number, Investor, State, Doc_type FROM MailTeamTracker " 'change oConn to reflect the Connection object you are using in your program oRS.Open strSQL, MyConn, adOpenForwardOnly, adLockReadOnly 'load the listview Do While Not oRS.EOF Set lvwItem = ListView1.ListItems.Add(, , oRS.Fields.Item("Date_Entered").Value, "mm/dd/yyy") lvwItem.SubItems(1) = oRS.Fields.Item("Loan_Number").Value 'change the date format as required lvwItem.SubItems(2) = Format(oRS.Fields.Item("Investor").Value) lvwItem.SubItems(3) = oRS.Fields.Item("State").Value 'change the date format as required lvwItem.SubItems(4) = Format(oRS.Fields.Item("Doc_Type").Value) oRS.MoveNext Loop oRS.Close Set oRS = Nothing End Sub




Reply With Quote