如果标准与数据表相匹配,我就试图做一个比较更新表格中含有源代码的表格。 如果该年度在2012年至2011年之间,那么该年度的标准就好像如下:
Thanks, Niki
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