将'many'Records限制为1:多个表格/子表单 [英] Limit 'many'Records in 1:many Form/Subform

查看:98
本文介绍了将'many'Records限制为1:多个表格/子表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表单/子表单组合,允许用户显示''ColorSet''

记录,通过选择器移动到其他记录,添加,删除和

编辑它们,并管理子表单中相关的颜色记录

即将完成,但我仍然需要帮助...


父表单的记录集有字段


字符串整数

COLORNAME CLASSSIZE以及其他一些与此无关的内容。


子表单与COLORNAME相关。


我现在可以添加,删除和编辑一个(表单)记录的字段

和许多(子表单)记录。


我需要将''很多''记录的数量限制为

CLASSSIZE值。父母的''''''记录。


我可以轻松编写代码来做到这一点,但我还没想出一个地方

把它。它不能进入​​形式

或子表单的before_update事件,我没有其他想法(gotfocus没有触发,

似乎如果它不管怎么说它会经常触发)。

当用户添加新的ColorSet记录时我都需要这种保护:

强制添加CLASSSIZE颜色,并强制颜色数量到

在任何后续编辑中等于修订后的CLASSSIZE。


我在哪里执行此限制?


谢谢, - thethelma

My form/subform combination that allows user to display ''ColorSet''
records, move to other records via a selector, to add,delete, and
edit them, and to manage the related ''Color'' records from the subform
is close to completion, but I still need help...

The parent form''s recordset has fields

string integer
COLORNAME CLASSSIZE and a few more that aren''t relevant here.

The child form is related by COLORNAME.

I can now add, delete and edit fields of both the one(form) records
and the many(subform) records.

I need to restrict the number of ''many'' records to exactly the
CLASSSIZE value of the parent form''s ''one'' record.

I can easily write code to do this, but I haven''t figured out a place
to put it. It can''t go into the before_update event of either the form
or subform and I have no other ideas (gotfocus didn''t trigger and
seems that if it did it would trigger too often anyway).
I need this protection both when user adds a new ColorSet record:
force addition CLASSSIZE colors, and also force number of colors to
equal the revised CLASSSIZE in any subsequent edit.

How [where?] do I enforce this restriction?

thanks, --thelma

推荐答案

你可以做一些事情,比如获取子表单的记录数量

recordsetclone然后如果该计数等于你的最大值,那么

你可以将AllowAdditions属性设置为false(你需要在onCurrent事件中更新它
更新它)主要形式。当你更新和插入查询正在运行时,你会变得很丑陋。

AFAIK,它'不容易......访问不会让你控制

表级事件的方式与SQL Server的方式相同...你可以使用

触发器。

you can do something like get the recordcount of the subform''s
recordsetclone and then if that count is equal to your maximum, then
you could set the AllowAdditions property to false (you''d need to
update it in the OnCurrent event of the main form. Gets ugly when you
want to enforce this when update and insert queries are running.
AFAIK, it''s not gonna be easy... Access doesn''t let you control
table-level events the way SQL Server does... where you could use
triggers.


如果表格中已存在相关的

项目的最大数量,则取消表格的Before Insert事件(DCount ()会告诉你。)


-

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

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

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


Thelma Lubkin <第**** @ alpha2.csd.uwm.edu>在消息中写道

news:dl ********** @ uwm.edu ...
Cancel the Before Insert event of the form if the maximum number of related
items already exists in the table (which DCount() will tell you.)

--
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.

"Thelma Lubkin" <th****@alpha2.csd.uwm.edu> wrote in message
news:dl**********@uwm.edu...
我的表单/子表单组合,允许用户显示' 'ColorSet''
记录,通过选择器移动到其他记录,添加,删除和编辑它们,以及管理子表单中相关的颜色记录
是接近完成,但我仍然需要帮助......

父表单'的记录集有字段

字符串整数
COLORNAME CLASSSIZE等等这里不相关。

儿童表格由COLORNAME联系。

我现在可以添加,删除和编辑一个(表格)记录的字段/>和许多(子表单)记录。

我需要将''many''记录的数量限制为父表单'''''的CLASSSIZE值。 ''记录。

我可以很容易地编写代码来做到这一点,但我还没想出一个放置它的地方。它不能进入​​形式
或子表单的before_update事件,我没有其他想法(getfocus没有触发,
似乎如果它确实会触发太频繁) 。
当用户添加新的ColorSet记录时,我需要这种保护:强制添加CLASSSIZE颜色,并强制颜色数量等于任何后续编辑中修改的CLASSSIZE。

我在哪里执行此限制?

谢谢, - thethelma
My form/subform combination that allows user to display ''ColorSet''
records, move to other records via a selector, to add,delete, and
edit them, and to manage the related ''Color'' records from the subform
is close to completion, but I still need help...

The parent form''s recordset has fields

string integer
COLORNAME CLASSSIZE and a few more that aren''t relevant here.

The child form is related by COLORNAME.

I can now add, delete and edit fields of both the one(form) records
and the many(subform) records.

I need to restrict the number of ''many'' records to exactly the
CLASSSIZE value of the parent form''s ''one'' record.

I can easily write code to do this, but I haven''t figured out a place
to put it. It can''t go into the before_update event of either the form
or subform and I have no other ideas (gotfocus didn''t trigger and
seems that if it did it would trigger too often anyway).
I need this protection both when user adds a new ColorSet record:
force addition CLASSSIZE colors, and also force number of colors to
equal the revised CLASSSIZE in any subsequent edit.

How [where?] do I enforce this restriction?

thanks, --thelma



Allen Browne <铝********* @ SeeSig.Invalid>写道:

:如果表格中已存在相关的

:项目的最大数量,则取消表格的Before Insert事件(DCount()将告诉您。)


我这样做。问题来了


1.用户完成的时间少于所需的

相关物品的数量。

2.其中用户减少了所需物品的数量[和

因此允许]并在制作足够的

删除之前离开。

--thelma

: -

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

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

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

:>我需要将很多记录的数量限制为

:>父表格'''''''记录的CLASSSIZE值。

:>
Allen Browne <Al*********@SeeSig.Invalid> wrote:
: Cancel the Before Insert event of the form if the maximum number of related
: items already exists in the table (which DCount() will tell you.)

I am doing this. The problems come

1. where the user finishes with fewer than the number of
related items required.
2. where the user reduces the number of items required [and
therefore allowed] and leaves before making enough
deletions.
--thelma
: --
: 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.
:> I need to restrict the number of ''many'' records to exactly the
:> CLASSSIZE value of the parent form''s ''one'' record.
:>


这篇关于将'many'Records限制为1:多个表格/子表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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