将子表单限制为1个条目 [英] Limit subform to 1 entry

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

问题描述

我有一个子表单frm_Obs在我的主窗体上frm_Main


如果没有记录,我希望用户能够添加一个。如果已经是一个,我希望用户能够更改它,但不再添加。


我尝试做的是向OnCurrent添加代码说:

I have a subform "frm_Obs" on my main form "frm_Main"

If there is no records, I want the user to be able to add one. If there allready is one, I want the user to be able to change it, but not add anymore.

What I tried doing was add code to OnCurrent saying:

展开 | 选择 | Wrap | 行号

推荐答案

你好TheSmileyOne,我真的跑出了门,所以我只是把它扔到那里给你测试。从主窗体的Current()事件执行以下代码,请记住,您可能必须在子窗体的Current()事件中复制它。当然,我假设子表格中目前存在不超过1条记录。我为匆忙道歉:
Hello TheSmileyOne, I am literally running out the door, so I am simply throwing this out there for you to test. Execute the following code from the Current() Event of the Main Form, keeping in mind that you may possibly have to duplicate it in the Current() Event of the Sub-Form. I''m assuming, of course, that there are currently no more than 1 Record existing in the Sub-Form. I apologize for the rush:
展开 | 选择 | Wrap | < span class =codeLinkonclick =LineNumbers(this);>行号


另一个选项是确保在主要时插入子表单的记录表格的记录是。因此,在Allowadditions之后没有麻烦。因为每条记录都在那里。

我经常在字段中使用默认值,例如<输入新数据>向用户显示它还没有被填充....


仍然是为什么你想要一个1:1关系而不是标准化的问题。 ..


Nic; o)
Another option is to make sure the subform''s record is inserted when the main form''s record is. Thus no hassle afterwards with "Allowadditions" as every record will be there.
I often use a default in a field like "<Enter new data>" to show the user it''s not filled yet....

Remains the question why you want to have a 1:1 relation which isn''t "normalized"...

Nic;o)


我不确定 是1:1这样尼科。它是1:?,在哪里? - >因此,没有必要将记录关联起来。只有那样,如果有,它永远不会超过单一。
I''m not sure it is a 1:1 as such Nico. It''s a 1:?, where ? -> 0 or 1. There is therefore no expectation necessarily of having a record associated. Only that, should there be any, it never exceeds the single one.


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

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