0

currently i am doing an order system, i need to create 2 filter to filter data from database and display in datagrid. First combobox is for order id and second combobox is for model id. Below is the description on the combobox function i need. At the end i had attached with my current coding(totally cant work...T_T). I am doing the data connection by adodc.

order id combobox: show all data in database and display data from selected order id in datagrid

model id combobox: only show model id under selected order id from order id combobox then display the final filter data in datagrid

eg: order ID abc123 consists 5 model ID (model 1,2,3,4 & 5). first select abc123 (all order id in database will show in combobox) from order id combobox, datagrid display all 5 model id information. Next, in model id combobox, model 1,2,3,4 & 5 been display only, select model 5, datagrid will show full data for abc123 and model 5 in datagrid

Private Sub Form_Load()

Adodc1.Refresh
Adodc1.Recordset.MoveFirst`
With Adodc1.Recordset`

Do Until .EOF
    cboOrderID.AddItem ![Order_ID]
    .MoveNext
    cboModelID.AddItem ![Model_ID]
    .MoveNext
Loop
End With

End Sub

Private Sub cboOrderID_Click()

Dim index As Integer
index = cboOrderID.ListIndex
Adodc1.RecordSource = "select * from Purchaser where Order_ID='" & cboOrderID & "'"

With Adodc1.Recordset

    Do Until .EOF
         cboModelID.AddItem ![Model_ID]
         .MoveNext
     Loop
 End With

End If
Adodc1.Refresh
DataGrid1.Refresh
Adodc1.Recordset.MoveFirst

End Sub

Private Sub cboModelID_Change()

Adodc1.RecordSource = "select * from Purchaser where Order_ID AND Model_ID='" & cboModelID & "'"
Adodc1.Refresh
DataGrid1.Refresh
Adodc1.Recordset.MoveFirst

End Sub
sean tan
  • 11
  • 1
  • 4

0 Answers0