|
楼主 |
发表于 2010-12-21 11:22
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
GP要在引号内: "select * from GP “ _
Sql = "select * from GP " _
& " where 周别='" & Format(ws.Cells(i, 1).Value) & "'" _
& " and 客户='" & ws.Cells(i, 2).Value & "'" _
& " and 课别='" & ws.Cells(i, 3).Value & "'" _
& " and 销售合同='" & ws.Cells(i, 4).Value & "'" _
& " and 产品名称='" & ws.Cells(i, 5).Value & "'" _
& " and 半成品='" & ws.Cells(i, 6).Value & "'" _
& " and 取数='" & ws.Cells(i, 7).Value & "'" _
& " and 准备工时='" & ws.Cells(i, 8).Value & "'" _
& " and 标准工时='" & ws.Cells(i, 9).Value & "'" _
& " and 标准产能='" & ws.Cells(i, 10).Value & "'" _
& " and 需求量='" & ws.Cells(i, 11).Value & "'" _
& " and 库存='" & ws.Cells(i, 12).Value & "'" _
& " and 交货量='" & ws.Cells(i, 13).Value & "'" _
& " and 计划量='" & ws.Cells(i, 14).Value & "'" _
& " and 交货日期='" & ws.Cells(i, 15).Value & "'" _
& " and 总工时='" & ws.Cells(i, 16).Value & "'" _
& " and 实绩完成='" & ws.Cells(i, 17).Value & "'" _
& " and 计划达成='" & ws.Cells(i, 18).Value & "'" _
& " and 备注='" & ws.Cells(i, 19).Value & "'"
Set rs = New ADODB.Recordset
rs.Open Sql, cnn, adOpenKeyset, adLockOptimistic
If rs.RecordCount = 0 Then
rs.AddNew
For j = 1 To rs.Fields.Count - 1
rs.Fields(j - 1) = ws.Cells(i, j).Value
Next j
rs.Update
Else
For j = 1 To rs.Fields.Count - 1
rs.Fields(j - 1) = ws.Cells(i, j).Value
Next j
rs.Update
End If
Next i
[ 本帖最后由 zez 于 2010-12-21 11:38 编辑 ] |
|