On the search form, there are two checkboxes: Active and Inactive.
When the program loads the Active checkbox is always ticked. If the user wants to view inactive products as well the should be able to have both ticked.
At the moment when I have active ticked, the listbox displays all active items and when I have Inactive only ticked it display Inactive items. However when I have both ticked, only inactive products are shown.
This is my code:
Private Sub cmdProdSearch_Click() Dim conn As ADODB.Connection Dim rs As ADODB.Recordset Dim list_item As ListItem Dim itm As ListItem db_file = db_file & "ProductsDatabase1.mdb" Set conn = New ADODB.Connection conn.ConnectionString = _ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\ProductsDatabase1.mdb;Persist Security Info=False" & _ "Data Source=" & db_file & ";" & _ "Persist Security Info=False" conn.Open Set rs = conn.Execute("Select * from Export where Product like '%" & txtProduct.Text & "%'") If chkActive.value = 1 Then Set rs = conn.Execute("Select * from Export where Inactive = '0'") Else Set rs = conn.Execute("Select * from Export where Inactive = '1'") ListView1.ListItems.Clear With ListView1 .View = lvwReport .FullRowSelect = True Do While Not rs.EOF Set itm = .FindItem(txtProduct.Text, lvwText, , lvwPartial) Set list_item = .ListItems.Add(, , rs!Product) list_item.SubItems(1) = rs!barcode & "" list_item.SubItems(2) = rs!quantity & "" list_item.SubItems(3) = rs!Department & "" list_item.SubItems(4) = rs!Active & "" list_item.SubItems(5) = rs!Inactive rs.MoveNext Loop End With End If End Sub
Also I am using an Access database to store product info, and am using SQL statements to find information.
Any suggestions as to be able to display bot Active and Inactive items when both checkboxes are ticked?