If Not conn.Execute("select * from 库存 Where 编号1='" & p1 & "'").EOF Or Not conn.Execute("select * from 采购订单清单 Where 编号2='" & b & "'").EOF Or Not conn.Execute("select * from 销货清单 Where 编号='" & b & "'").EOF Or Not conn.Execute("select * from 盘点清单 Where 编号5='" & b & "'").EOF Or Not conn.Execute("select * from 物料清单 Where 编号3='" & b & "'").EOF Then
MsgBox "该编号因已存在数据不能修改!", 64如果有1000个表,那就麻烦了,帮简化一下这条语句???
MsgBox "该编号因已存在数据不能修改!", 64如果有1000个表,那就麻烦了,帮简化一下这条语句???
declare @table table (tablename varchar(12),colname varchar(5),dname varchar(2))
insert into @table
select '库存','编号1','p1' union all
select '采购订单清单','编号2','b' union all
select '销货清单','编号','b' union all
select '盘点清单','编号5','b' union all
select '物料清单','编号3','b'select 'select * from '+tablename+
' where '+colname+'='''+dname+'''' from @table
/*
select * from 库存 where 编号1='p1'
select * from 采购订单清单 where 编号2='b'
select * from 销货清单 where 编号='b'
select * from 盘点清单 where 编号5='b'
select * from 物料清单 where 编号3='b'
*/
表名无规律,字段还不一样,变量还一样可以按我上面的方式,然后循环。