我添加了一个过滤方法,按部门过滤选择组合框选项,但是,我不知道如何在从数据库查询后将数据推送到列表中。以下是我的代码。
Private Sub comboDept_Click()
Dim sQuery As String
Dim oRS As New ADODB.Recordset
Dim oRS_PR As New ADODB.Recordset
Dim sPONO As String
Dim sPOAmt As String
combVal = comboDept.List(comboDept.ListIndex)
If combVal = "EIBU_SALES" Then
sQuery = "Select PO_No, PO_Requestor, PO_Req_Dept, PO_Status, PO_Approval_M, PO_Approval_GM, PO_Approval_D, PO_HRApproval, VC_No, TH_Sup_Inv, PO_HR_Rmk, PO_Req_Date, PO_SupplierName, PO_OverallAmt from PR_INFO where PO_Req_Dept = '" & combVal & "'"
oRS_PR.Open sQuery, PRCnn, adOpenDynamic, adLockOptimistic
ElseIf comboDept.List(comboDept.ListIndex) = "MCBU_SALES" Then
答案 0 :(得分:0)
尝试这样的事情(它只是一个提示;你必须调整代码):
' Empty list
myListView.ListItems.Clear
' Add items
While (Not oRS_PR.EOF)
Set item = myListView.ListItems.Add(, , oRS_PR!FIRST_COLUMN)
item.SubItems(...) = oRS_PR!SOME_COLUMN
item.SubItems(...) = oRS_PR!OTHER_COLUMN
oRS_PR.MoveNext
Wend