|
本帖最后由 icedragonking 于 2020-7-9 10:58 编辑
需要实现的功能很简单,就是从[同发物料]sheet中根据MaterialNumber字段汇总求和同发skus字段,然后再把汇总求和得到的数据去匹配[物料频次]sheet中的Material Number字段,对应的更新到同发skus字段。运行中途报错如下,跪求大神帮忙解决!
以下是同发物料sheet
同发物料
以下是物料频次sheet
物料频次
具体代码如下:
Sub 汇总()
Dim adoconn As New ADODB.Connection
Dim strconn As String
Dim strsql As String
ThisWorkbook.Application.ScreenUpdating = False
Application.DisplayAlerts = False
adoconn.Mode = adModeReadWrite
strconn = "Provider=microsoft.ace.oledb.12.0;data source=" & ThisWorkbook.FullName & ";extended properties=""excel 12.0;hdr=yes;imex=0"";"
adoconn.Open strconn
strsql = "UPDATE [物料频次$] as a SET a.同发skus = DSum([同发skus],'[同发物料$]','MaterialNumber=' & [a].[Material Number]) WHERE a.[Material Number] Is Not Null"
adoconn.Execute (strsql)
adoconn.Close
Set adoconn = Nothing
ThisWorkbook.Application.ScreenUpdating = Ture
Application.DisplayAlerts = Ture
End Sub
运行中途报错如下:
报错
|
|