|
楼主 |
发表于 2012-3-7 20:16
|
显示全部楼层
问题解决,请各位老师帮看看,是否方法过于笨拙
本帖最后由 aonly999 于 2012-3-11 00:26 编辑
Private Sub Command0_Click()
Dim cn As New adodb.Connection
Dim rs_mx As New adodb.Recordset
Dim rs_ly As New adodb.Recordset
Dim sql As String
Dim code As String
Dim con1 As Variant
Dim con2 As Variant
Dim con3 As Variant
Dim con4 As Variant
Set cn = CurrentProject.Connection
rs_mx.LockType = adLockOptimistic
rs_ly.Open "select * from 理由分类", cn
rs_ly.MoveFirst
Do While Not rs_ly.EOF
code = rs_ly!分类代码
con1 = rs_ly!关键字1
con2 = rs_ly!关键字2
con3 = rs_ly!关键字3
con4 = rs_ly!关键字4
sql = "SELECT * FROM 退货明细 WHERE ("
sql = sql & "(InStr([退货理由], '" & con1 & "') > 0) and "
sql = sql & "(InStr([退货理由], '" & con2 & "') > 0) and "
sql = sql & "(InStr([退货理由], '" & con3 & "') > 0) and "
sql = sql & "(InStr([退货理由], '" & con4 & "') > 0) and "
sql = sql & " isnull ([分类代码]) )"
rs_mx.Open sql, cn
Do While Not rs_mx.EOF
rs_mx!分类代码 = code
rs_mx.MoveNext
Loop
rs_mx.Close
rs_ly.MoveNext
Loop
rs_ly.Close
cn.Close
Set rs_mx = Nothing
Set rs_ly = Nothing
Set cn = Nothing
MsgBox "更新成功!"
End Sub
|
|