如果条件与 DataSelect 表匹配,我正在尝试执行一个循环,该循环将使用表 DataSelect 中的源代码更新表 Cleaned。标准的示例就像年份在 2012 年和 2011 年之间,频道就像TM和 MRC 介于 5 和 10 之间。我创建 DataSelect 来保存所有不同类型的标准,我希望程序循环遍历每个分配的标准清理了源代码。到目前为止,我总是收到“参数太少。预期 1。运行时错误 3061。” 任何帮助将不胜感激。
谢谢,尼基
Private Sub doDataSegm_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL, strSearch, strReplace As String
Set db = CurrentDb()
Set rs = db.OpenRecordset("dataselect", dbOpenTable)
If rs.RecordCount = 0 Then Exit Sub
rs.MoveFirst
For i = 1 To rs.RecordCount
strChan = rs("Chan")
strDataCode = rs("code")
strMrcYrLow = rs("mrcyr_low")
strMrcYrhigh = rs("mrcyr_high")
strMrcLow = rs("mrc_low")
strMrchigh = rs("mrc_high")
strSQL = "UPDATE Cleaned SET [cleaned].[datacode]= " & _
strDataCode & " where [CLEANED].[CHANNEL] Like '" & strChan & _
"' AND [CLEANED].[MRC_YEAR] Between '" & strMrcYrLow & _
"' And '" & strMrcYrhigh & "' AND CLEANED.MRC Between " & _
strMrcLow & " And " & strMrchigh & ";"
db.Execute strSQL, dbFailOnError
rs.MoveNext
Next i
End Sub