|
本帖最后由 123736485 于 2015-5-15 13:44 编辑
如图下数据
ACC数据库
VBA语句:
Sub 存入ACC数据库()
'Private Sub CommandButton1_Click()
Dim cnn As Object, SQL$, 单号&
Set cnn = CreateObject("adodb.connection")
cnn.Open "Provider=Microsoft.ace.OLEDB.12.0;Data Source=" & ThisWorkbook.Path & "\不良品数据库.mdb"
SQL = "select 成品编号,规格,原因描述,数量,备注,#" & Format([H6], "yyyy-m-d") & "# as 时间," & [H4] & "' as 单据编号,'" & [C4] & "' as 组别,'" & [C6] & "' as 流程,'" & [C12] & "' as 登记人 from [Excel 12.0;Database=" & ThisWorkbook.FullName & "].[PFSQD$C7:H" & Cells(Rows.Count, 3).End(3).Row & "]"
SQL = "insert into 不良品明细表 select * from (" & SQL & ")" '添加记录
cnn.Execute SQL
MsgBox "已将数据保存到access中", vbInformation
cnn.Close
Set cnn = Nothing
'End Sub
End Sub
提示from子句语法错误
Execl文档有用VBA做的用户登陆验证,是否有影响?
应如何修改VBA语句?
请高手帮忙解答,感谢!
|
-
录入表
|