when i select option button of fastfood it retrieve the data in two listbox from database.
i m using 4 list box one(check style list box) is for food item another(simple list box) is for cost. when i selects(checked) any fooditem then a inputbox will occur for entry of food quantity. and after selecting two item the input box occur before checked 3rd item and it multiply with previous item cost instead of current item's cost.
please check this error.......
after selecting the item their cost will multiply with the quantity which is given by inputbox and their multiply will send into 4th list box named lstcost & that item will send in 3rd listbox named lstfood.
This is my coding
Dim rs As New ADODB.Recordset Dim i As Integer Dim var As Integer Private Sub Form_Load() con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=g:\ak.mdb;Persist Security Info=False" rs.Open " select* from table1", con, adOpenDynamic, adLockOptimistic End Sub Private Sub List1_Click() For i = 0 To List1.ListCount - 1 If List1.Selected(i) = True Then var = InputBox("enter quantity") lstcost.AddItem var * (List2.List(i)) End If Next i End Sub Private Sub Command1_Click() For i = 0 To List1.ListCount - 1 If List1.Selected(i) Then Form1.lstfood.AddItem List1.List(i) End If Next i End Sub Private Sub Option1_Click() If rs.State = adStateOpen Then rs.Close End If rs.Open "select productname,cost from table1 where category='ff'" If Not rs.EOF Then rs.MoveFirst Do While Not rs.EOF List1.AddItem rs!ProductName List2.AddItem rs!cost rs.MoveNext Loop rs.Close End Sub
Edited 5 Years Ago by Ezzaral: Added code tags. Please use them to format all code that you post.