->I'm a Computer Science major, currently the project leader for our Computer Programming 3 thesis... Despite being the project leader, I do all the work... So I came here to ask for some Visual Basic help... No advanced stuff please, we're still on the basics so my professor would probably get suspicious if I use some weird code....
Anyway, could anyone take a look at this code? I can't, for the love of Blizzard, seem to make it run properly... It always catches a different error every time I try to change it, specifically the Sub on the Textbox:
Sub FillListView()
ListView1.ListItems.Clear
dbConnect
rs.Open "Select * from tblProducts", db, 1, 2
Do Until rs.EOF = True
Dim lst As ListItem
Set lst = ListView1.ListItems.Add(, , rs!pID)
lst.SubItems(1) = rs!pName
lst.SubItems(2) = rs!pCategory
lst.SubItems(3) = rs!pSubCategory
lst.SubItems(4) = rs!pColor
lst.SubItems(5) = rs!pSize
lst.SubItems(6) = rs!pSizeType
lst.SubItems(7) = rs!pPrice
lst.SubItems(8) = rs!pSupplier
lst.SubItems(9) = rs!pInStock
lst.SubItems(10) = rs!pReorderQty
lst.SubItems(11) = rs!pMiscDetails
rs.MoveNext
Loop
rs.Close
dbDisconnect
End Sub
Private Sub Form_Load()
cboSearchBy.AddItem "Product Name"
cboSearchBy.AddItem "Category"
cboSearchBy.AddItem "Color"
cboSearchBy.AddItem "Size Type"
cboSearchBy.AddItem "Supplier"
cboSearchBy.Text = "Product Name"
FillListView
End Sub
Private Sub txtKeyword_Change()
ListView1.ListItems.Clear
dbConnect
rs.Open "Select * from tblProducts where " & cboSearchBy.Text & " like '" & txtKeyword.Text & "%'", db, 1, 2
Do Until rs.EOF = True
Dim lst As ListItem
Set lst = ListView1.ListItems.Add(, , rs!pID)
lst.SubItems(1) = rs!pName
lst.SubItems(2) = rs!pCategory
lst.SubItems(3) = rs!pSubCategory
lst.SubItems(4) = rs!pColor
lst.SubItems(5) = rs!pSize
lst.SubItems(6) = rs!pSizeType
lst.SubItems(7) = rs!pPrice
lst.SubItems(8) = rs!pSupplier
lst.SubItems(9) = rs!pInStock
lst.SubItems(10) = rs!pReorderQty
lst.SubItems(11) = rs!pMiscDetails
rs.MoveNext
Loop
rs.Close
dbDisconnect
End Sub
Answers ASAP please... Thanks!
†