以文本方式查看主题

-  易表在线答疑  (http://egrid2000.com/dvbbs/index.asp)
--  用户社区  (http://egrid2000.com/dvbbs/list.asp?boardid=2)
----  求助:两表合一问题 急!急!急!  (http://egrid2000.com/dvbbs/dispbbs.asp?boardid=2&id=42085)

--  作者:redpin
--  发布时间:2022/11/3 8:12:00
--  求助:两表合一问题 急!急!急!


此主题相关图片如下:微信图片_20221103080153.png
按此在新窗口浏览图片

需要把B表中与A表中相同的记录删除形成新的C表。


DelFor("C表","记录", "<>" ,"") And
AddRow("C表","x_ID,记录",[x_ID],FindText("A表","记录","x_ID", "=" ,""))


用上面公式设计成按钮有问题吗?

 

开始用上面公式似乎成功实现了目的,但再此执行后就把C表中的记录全部删除了,再怎么折腾也没结果了!

 

感谢各位大侠赐教,谢谢!


--  作者:redpin
--  发布时间:2022/11/3 8:27:00
--  

不好意思,公式复制错了

 

DelFor("C表","记录", "<>" ,"") And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",2)) And

DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",3)) And

DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",4)) And

DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",5)) And

DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",6)) And

..............

 

直到把A表中符合条件的记录做完


--  作者:redpin
--  发布时间:2022/11/3 8:30:00
--  
首先把B表记录添加到C表
--  作者:redpin
--  发布时间:2022/11/3 8:46:00
--  

完整公式

 

DelFor("C表","记录", "<>" ,"") And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录1","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录2","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录3","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录4","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录5","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录6","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录7","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录8","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录9","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录10","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录11","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录12","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录13","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录14","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录15","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录16","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录17","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录18","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录19","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录20","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录21","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录22","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录23","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录24","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录25","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录26","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录27","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录28","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录29","x_ID", "=" ,"")) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录30","x_ID", "=" ,"")) And
DelReptRows("C表","记录") And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",2)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",3)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",4)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",5)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",6)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",7)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",8)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",9)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",10)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",11)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",12)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",13)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",14)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",15)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",16)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",17)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",18)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",19)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",20)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",21)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",22)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",23)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",24)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",25)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",26)) And
RecalcRow("C表",1,1,1)


--  作者:redpin
--  发布时间:2022/11/3 9:06:00
--  
如果有几千上万的记录,这个公式又怎么写?
--  作者:redpin
--  发布时间:2022/11/3 9:29:00
--  

再次把公式修改,去掉了首行的单元格公式,还是没有结果

 

DelFor("C表","记录", "<>" ,"") And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",2)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",3)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",4)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",5)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",6)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",7)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",8)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",9)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",10)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",11)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",12)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",13)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",14)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",15)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",16)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",17)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",18)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",19)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",20)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",21)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",22)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",25)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",26)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",27)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",28)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",29)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",30)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",31)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",32)) And
AddRow("C表","x_ID,记录",[x_ID],FindText("B表","记录","x_ID", "=" ,"",33)) And
DelReptRows("C表","记录") And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",2)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",3)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",4)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",5)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",6)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",7)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",8)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",9)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",10)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",11)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",12)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",13)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",14)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",15)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",16)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",17)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",18)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",19)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",20)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",21)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",22)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",23)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",24)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",25)) And
DelFor("C表","记录", "=" ,FindText("A表","记录","x_ID", "<>" ,"",26)) And
RecalcRow("C表",1,1,1)


--  作者:redpin
--  发布时间:2022/11/3 10:53:00
--  

已解决目前A、B两表记录很少的问题,是部分条件引用错误造成的,如果两表记录很多,这个公式是肯定解决不了问题的!