通过表单从Access联结表中删除行 [英] Delete row from Access junction table via form

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

问题描述

我设置了一个子表单列出来自联结和查找表的存储值.这部分运行良好(我可以查看所有存储的条目或添加新条目).

I set up a subform listing stored values from a junction and lookup table. This part is working nicely (I can view all stored entries or add new ones).

这是我的关系:

这是表单的布局,显示了我尝试删除以前保存的关联的位置.如果我只是删除表单中该行的内容,则当我尝试保存记录时,Access将返回以下内容:index or primary key cannot contain null value

And here's the layout of my form showing where I attempted to remove a previously saved association. If I simply delete the contents of the row in the form, Access returns this when I try to save the record: index or primary key cannot contain null value

从控制台删除行的SQL很简单:

The SQL to remove a row from a console is straightforward:

DELETE FROM junction_model WHERE cust_id = X AND model_id = Y

事实证明,从表单中删除一行并不是那么简单.

Removing a row from the form is proving not to be as straightforward.

从表单本身是否有相对简单的方法?

Is there a relatively easy way of doing this from the form itself?

推荐答案

组合框左侧的那些小方块(其中一个带有铅笔"图标,表示记录不干净)是记录选择器" ".单击记录选择器将选择该记录,然后如果您单击删除,该记录将被删除.

Those little squares to the left of the combo boxes (one of which has a "pencil" icon in it, indicating a dirty record) are the "record selectors". Clicking a record selector will select the record, then if you hit Delete the record will be deleted.

您似乎刚刚删除了组合框的内容.当您保存(尚存的)记录时,Access遭到反对,因为组合框的.ValueNull,并且联结表上的主键禁止[model_id]的Null值.

It looks like you just deleted the contents of the combo box. When you went to save the (still-existing) record Access objected because the .Value of the combo box was Null, and your Primary Key on the junction table prohibits Null values for [model_id].

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

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