|
知道了。把你CheckBox6的那段If循环代码,改成这样就差不多了
If CheckBox6 Then
Dim rst As New ADODB.Recordset
Dim s As String
Dim mytable As String
mytable = "计划表"
names = "型号"
number = Trim(Sheet2.Cells(3, 7))
s = "select * from " & mytable & " where " & names & "='" & number & "'"
If CheckBox7 = True Then
number = Trim(Sheet2.Cells(3, 8))
names = "电压"
s = s & " and " & names & " = '" & number & "'"
CheckBox7.Value = False
End If
If CheckBox9 = True Then
number = Trim(Sheet2.Cells(3, 11))
names = "规格"
s = s & " and " & names & " = '" & number & "'"
CheckBox9.Value = False
End If
Call connectdata
rst.Open s, data, adOpenDynamic, adLockOptimistic
Sheet2.Cells(8, 1).CopyFromRecordset rst
Set data = Nothing
Set rst = Nothing
End If
Exit Sub |
|