|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub 宏1()
Rows("5:5000").Delete Shift:=xlUp
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:="OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" & ThisWorkbook.Path & "\SpecForApproval.accdb", Destination:=Range("$A$5")).QueryTable
.CommandType = xlCmdSql
sqlstr = "SELECT [0].ID, [00].品名型号, [00].研发型号, [00].承认书编号, [00].版本号, [00].日期, [02].DCRTyp, [02].DCR, [02].Isat, [02].Itemp, [01].A, [01].B, [01].C, [01].D, [00].客户, [00].备注说明"
sqlstr = sqlstr & " FROM ((0 INNER JOIN 00 ON [0].承认书编码 = [00].承认书编码) INNER JOIN 01 ON [00].承认书编码 = [01].承认书编码) INNER JOIN 02 ON [01].承认书编码 = [02].承认书编码"
sqlstr = sqlstr & " WHERE ((([00].品名型号) Like '%730%'))"
.CommandText = sqlstr
.ListObject.DisplayName = "表_1"
.Refresh BackgroundQuery:=False
End With
End Sub
|
|