默认情况下, access没法批量执行命令,变通的方式在编辑器里面编辑,然后再vba里面以数组的方式逐个执行:
private sub product_spec()
dim arr(20) as variant
arr(0)="UPDATE 库存 set [规格]=""1000*360"" where [产品名] like ""*产品1*"""
arr(1)="UPDATE 库存 set [规格]=""4480*260"" where [产品名] like ""*产品2*"""
arr(2)="UPDATE 库存 set [规格]="""" where [产品名] like ""*产品3*"""
arr(3)="UPDATE 库存 set [规格]="""" where [产品名] like ""*产品4*"""
arr(4)="UPDATE 库存 set [规格]="""" where [产品名] like ""*产品5*"""
arr(5)="UPDATE 库存 set [规格]=""2000*1980*450"" where [产品名] like ""*产品6*"""
arr(6)="UPDATE 库存 set [规格]=""2090*1890*1100"" where [产品名] like ""*产品7*"""
arr(7)="UPDATE 库存 set [规格]=""1570*850*450"" where [产品名] like ""*产品8*"""
arr(8)="UPDATE 库存 set [规格]=""2200*400*530"" where [产品名] like ""*产品9*"""
arr(9)="UPDATE 库存 set [规格]=""1950*965*450"" where [产品名] like ""*产品10*"""
arr(10)="UPDATE 库存 set [规格]=""1950*965*450"" where [产品名] like ""*产品11*"""
arr(11)="UPDATE 库存 set [规格]=""1480*760*850"" where [产品名] like ""*产品12*"""
arr(12)="UPDATE 库存 set [规格]=""2380*600*1063"" where [产品名] like ""*产品13*"""
arr(13)="UPDATE 库存 set [规格]=""450*35*1820"" where [产品名] like ""*产品14*"""
arr(14)="UPDATE 库存 set [规格]=""400*300*420"" where [产品名] like ""*产品15*"""
arr(15)="UPDATE 库存 set [规格]=""400*300*420"" where [产品名] like ""*产品16*"""
arr(16)="UPDATE 库存 set [规格]=""400*300*420"" where [产品名] like ""*产品17*"""
arr(17)="UPDATE 库存 set [规格]=""300*300*320"" where [产品名] like ""*产品18*"""
arr(18)="UPDATE 库存 set [规格]=""300*300*320"" where [产品名] like ""*产品19*"""
arr(19)="UPDATE 库存 set [规格]=""300*300*320"" where [产品名] like ""*产品20*"""
arr(20)="UPDATE 库存 set [规格]=""498*338*1050"" where [产品名] like ""*产品21*"""
For i = LBound(arr) To UBound(arr)
debug.print arr(i)
docmd.setwarngs false
docmd.runsql arr(i)
next i
end sub
网友评论