帮助:当子表单为空时,如何防止移动到新记录? [英] Help: How to prevent moving to the new record when sub form is null?

查看:63
本文介绍了帮助:当子表单为空时,如何防止移动到新记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在NorthWind示例数据库中,点击新订单记录上的下一个

导航按钮,子窗体上没有任何内容

(订单详情),我们订单没有订购。我们怎样才能阻止这种情况发生?

谢谢。

ming

Hi, in the NorthWind sample database, when clicking on the next
navigation button on the new order record with nothing on the subform
(order details), we got an order with nothing ordered. How can we
prevent this from happening?
Thanks.
ming

推荐答案

在设计视图中打开子表单的表格。

选择外键字段(与主表单相关的字段)

表。)

在下方窗格中,将Required属性设置为Yes。


这可以防止孤立记录,但是用户没有消息直到他们已经完成了在子表单中记录的
。你也可以取消

子表格'的插入前事件程序:


Private Sub Form_BeforeInsert(取消为整数)

如果Me.Parent.NewRecord那么

取消=真

MsgBox"首先输入主表单记录。

结束如果

结束Sub


-

Allen Browne - 微软MVP。西澳大利亚州珀斯。

访问用户提示 - http:// allenbrowne.com/tips.html

回复群组,而不是mvps dot org的allenbrowne。


" swingingming" < MI ****** @ gmail.com>在消息中写道

news:11 ******************** @ g43g2000cwa.googlegrou ps.com ...
Open your subform''s table in design view.
Select the foreign key field (the one that relates to the main form''s
table.)
In the lower pane, set the Required property to Yes.

This prevents orphan records, but the user gets no message until they have
finished entering their record in the subform. You can also cancel the
subform''s Before Insert event procedure:

Private Sub Form_BeforeInsert(Cancel As Integer)
If Me.Parent.NewRecord Then
Cancel = True
MsgBox "Enter the main form record first."
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"swingingming" <mi******@gmail.com> wrote in message
news:11********************@g43g2000cwa.googlegrou ps.com...
在NorthWind示例数据库中,当点击新订单记录上的下一个
导航按钮时,子表单上没有任何内容
(订单详情),我们得到的订单没有订购。我们怎样才能防止这种情况发生?
谢谢。
ming
Hi, in the NorthWind sample database, when clicking on the next
navigation button on the new order record with nothing on the subform
(order details), we got an order with nothing ordered. How can we
prevent this from happening?
Thanks.
ming



swingingming< mi **** **@gmail.com>写道:
swingingming <mi******@gmail.com> wrote:
您好,在NorthWind示例数据库中,当点击新订单记录上的下一个
导航按钮时,子表单上没有任何内容
(订单详情),我们得到了没有订购的订单。我们怎样才能防止这种情况发生?
谢谢。
ming
Hi, in the NorthWind sample database, when clicking on the next
navigation button on the new order record with nothing on the subform
(order details), we got an order with nothing ordered. How can we
prevent this from happening?
Thanks.
ming




按设计访问将移至新的记录

a表格记录集的结尾。所以它不是一个空白的订单,而是一个新的订单,在输入一些信息之前不会以

a记录存在(你会看到小图标

in左栏更改)。


您可以通过关闭表单的Allow Additions属性

来停止此行为。但是你不能添加新的记录,除非你用
设计一种不同的方式来做它。

-

问候,


布拉德利


基督徒的回应
http://www.pastornet.net.au/response


艾伦,谢谢你很多你的回复!!

你的解决方案听起来不错,但我已经将外键设置为

所需。我所指的记录导航按钮是主窗体上的



在我想到它之后,我想阻止主要记录

表格停止保存,如果另一个弱实体(OrderDetails,外键:

OrderID - 来自Orders表,ProductID来自Products表)是

空。在访问中这可能是不可能的。

问候,

ming

Allen, thank you very much for your reply!!
Your solution sounds good, but I already set the foreign key to
required. And the record navigation button I am referring to is the
ones on the main form.
After I think more about it, I wanted to prevent the record on the main
form to stop saving if another weak entity (OrderDetails, foreign keys:
OrderID--from Orders table, and ProductID from Products table) is
empty. This maybe impossible in Access.
Regards,
ming


这篇关于帮助:当子表单为空时,如何防止移动到新记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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