|
Dim i%, j%, mydata$
mydata = ThisWorkbook.Path & "\配件表.mdb"
Set Cnn = New ADODB.Connection
With Cnn
.Provider = "microsoft.jet.oledb.4.0"
.Open mydata
End With
For i = 1 To 7
Str = Me.Controls("ComboBox" & i).Value
If Len(Str) Then Stg = Stg & IIf(Len(Stg), " And ", "") & Me.Controls("Label" & i).Caption & " Like '%" & Str & "%'"
Next
SQL = "Select * From 零配件名称表" & IIf(Len(Stg), " Where " & Stg, "")
rs.Open SQL, Cnn, adOpenKeyset, adLockOptimistic
With ListView2
.ColumnHeaders.Clear
.ListItems.Clear
.View = lvwReport
.FullRowSelect = True
.Gridlines = True
For i = 0 To rs.Fields.Count - 2
.ColumnHeaders.Add , , rs.Fields(i).Name
Next i
.ListItems.Clear
For i = 1 To rs.RecordCount
.ListItems.Add , , rs.Fields(0).Value
For j = 1 To rs.Fields.Count - 2
If rs.Fields(j).Value <> "" Then
.ListItems(i).SubItems(j) = rs.Fields(j).Value
Else
.ListItems(i).SubItems(j) = ""
End If
Next j
rs.MoveNext
Next i
End With
rs.Close
Set rs = Nothing
Set Cnn = Nothing
Label9.Caption = "共查到" & ListView2.ListItems.Count & "条记录" |
|