English 中文(简体)
• 如何利用更新的问答——准入
原标题:How to do a loop with update query - Access

如果标准与数据表相匹配,我就试图做一个比较更新表格中含有源代码的表格。 如果该年度在2012年至2011年之间,那么该年度的标准就好像如下:TM/em>,而MRC则在5至10之间。 我创立了数据选择,以掌握所有不同类型的标准,我希望该方案在源代码中逐个安排。 到目前为止,我总是看到“几个参数。 检查 1. 时间错误 3061 任何帮助都将受到高度赞赏。

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
最佳回答

象“很少参数”这样的信息。 检查 1. 时间错误3061 通常表明,你的询问含有未经引述的数据价值,而查阅则将数据价值解释为外地名称。 由于你询问中唯一未引用的识别符号是/codeMRC,因此,你认为需要引用其中的一种:

UPDATE Cleaned SET [Cleaned].[datacode] =  " & strDataCode & "  ...
                                          ^ ...add quotes...  ^
问题回答

暂无回答




相关问题
Handling no results for docmd.applyfilter

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the ...

Outlook 2007 CommandBarControl.Execute won t work

I recently switched to Outlook 2007 and noticed that my VBA-macros won t work. I use the following code to open a new appointment-item (and fill it automatically). It worked perfect in Outlook 2003, ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

MS Access: list macro from VBA

I have to deal with a few macros (not VBA) in an inherited Access application. In order to document them, I would like to print or list the actions in those macros, but I am very dissatisfied by ...

热门标签