从另一个表中删除一个表 [英] Delete one Table from Another

查看:127
本文介绍了从另一个表中删除一个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我是VBA和MS Access的新手(我正在使用2003),但我的问题看起来非常简单。我想从另一个表中删除在一个表中找到的所有记录。


我有代码从列表框中获取值(其源代码为tblNewModPart)然后使用它们在Make-Table查询中创建一个名为tblRemovedParts的表。我想删除tblRemovedParts中的所有值。来自tblNewModPart。


我试过设置一个删除查询,其中包含按部件号连接的两个表,但是当我尝试运行查询时,会弹出一条错误消息 ;指定包含要删除的记录的表。


删除查询的代码为:

展开 | 选择 | Wrap | 行号

解决方案

在这种情况下,加入表格不起作用。


最好在运行查询之前先备份像这样!


一般认可ch是使用子查询,如:


delete * from tblRemovedParts其中PartNum in(从tblNewModPart中选择PartNum)


这需要所有PartNum要删除的内容可以在tblNewModPart中找到。


得到这个想法?


Nic; o)


在这种情况下,加入表格不起作用。

最好在运行查询之前先进行备份这是一个通用的方法是使用子查询,如:


delete * from tblRemovedParts其中PartNum in(从tblNewModPart中选择PartNum)


这要求在tblNewModPart中找到要删除的所有PartNum。


得到这个想法?

Nic; o)



感谢您的快速回复。我想我明白了。我不是试图加入这两个表,而是从另一个表中选择所有部件号。我想这就是我首先尝试做的事情,但我对MS Access的了解非常有限。谢谢!



大家好,我是VBA和MS Access的新手(我正在使用2003)但我的问题看起来很简单。我想从另一个表中删除在一个表中找到的所有记录。


我有代码从列表框中获取值(其源代码为tblNewModPart)然后使用它们在Make-Table查询中创建一个名为tblRemovedParts的表。我想删除tblRemovedParts中的所有值。来自tblNewModPart。


我试过设置一个删除查询,其中包含按部件号连接的两个表,但是当我尝试运行查询时,会弹出一条错误消息 ;指定包含要删除的记录的表。


删除查询的代码为:

展开 | 选择 | Wrap | 行号

Hello everyone, I''m fairly new to VBA and MS Access (I''m using 2003) but my issue seems like a pretty straight forward one. I would like to delete all records found in one table from another one.

I have code which grabs values from a list box (which has as its source "tblNewModPart") then uses them in a Make-Table query which creates a table called "tblRemovedParts." I would like to delete all values from "tblRemovedParts" from "tblNewModPart."

I''ve tried setting up a Delete-query which contains the two tables joined by part number, but when I try to run the query, it pops up an error message saying "Specify the table containing the records you want to delete."

The code for the delete query is:

Expand|Select|Wrap|Line Numbers

解决方案

Joining tables won''t work in this case.

Best to make first a backup before running a query like this !

One general approach is to use a subquery like:

delete * from tblRemovedParts where PartNum in (Select PartNum from tblNewModPart)

This requires that all PartNum''s to be removed are found in tblNewModPart.

Getting the idea?

Nic;o)


Joining tables won''t work in this case.

Best to make first a backup before running a query like this !

One general approach is to use a subquery like:

delete * from tblRemovedParts where PartNum in (Select PartNum from tblNewModPart)

This requires that all PartNum''s to be removed are found in tblNewModPart.

Getting the idea?

Nic;o)


Thanks for the quick reply. I think I get it. Instead of trying to join the two tables, I''ll instead just select all part numbers from the other table. I suppose thats what I was trying to do in the first place, but my knowledge of MS Access is pretty limited. Thanks!


Hello everyone, I''m fairly new to VBA and MS Access (I''m using 2003) but my issue seems like a pretty straight forward one. I would like to delete all records found in one table from another one.

I have code which grabs values from a list box (which has as its source "tblNewModPart") then uses them in a Make-Table query which creates a table called "tblRemovedParts." I would like to delete all values from "tblRemovedParts" from "tblNewModPart."

I''ve tried setting up a Delete-query which contains the two tables joined by part number, but when I try to run the query, it pops up an error message saying "Specify the table containing the records you want to delete."

The code for the delete query is:

Expand|Select|Wrap|Line Numbers


这篇关于从另一个表中删除一个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆