控制标签键 [英] Control Tab key

查看:114
本文介绍了控制标签键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个数据输入表单。目前,您可以使用Tab键将表单字段移动到表单中的字段。我遇到的问题是,如果在表单的最后一个字段中输入信息后使用tab键,则光标移动到新记录的第一个字段。这会导致表中的大量空白记录。如何关闭Tab键,使其不会自动启动新记录。

我已将此表单设置为从另一个表单启动,以便加载的新数据集将从上一个表单中获取记录ID(父/子关系)。在数据输入表单上,我创建了一个按钮,它将添加正确的id以维持这种关系。在填充最后一个字段后使用tab键时,不会记录任何记录ID。这就是为什么我不想让tab键开始新记录。

I have created a data input form. Currently you can use the tab key to move form field to field within the form. the problem I am having is that if the tab key is used after entering information in the last field of the form, the cursor moves to the first field of a new record. this causes a lot of blank records in the table. How can I turn off the tab key so that it does not automatically start a new record.
I have this form set up to be launched from another form so that the new set of data being loaded will pick up the Record Id from the previous form (parent/child relationship). On the data input form I have created a button that will add the proper id to maintain this relationship. When the tab key is used after the last field is populated no record id is carried over. this is why I don''t want the tab key to start a new record.

推荐答案

嗨布鲁斯。


有一个名为BeforeUpdate事件的表单的事件,其中包含取消参数。当此参数设置为 True 时,更新不会发生。它基本上已退出或取消。此外,Access窗体旨在一旦您离开当前记录就可以保存记录。从本质上讲,当你在窗体上导航到该记录的最后一个控件之后,就会发生这种情况。


所以,如果你想要避免进入下一条记录意外,因为它,然后我会建议两个步骤:
Hi Bruce.

There is an Event for a form called the BeforeUpdate event which has a Cancel parameter. When this parameter is set to True then the update doesn''t happen. It''s essentially backed-out or cancelled. Also, Access forms are designed to save records once you navigate away from the current record. Essentially, this is what''s happening when you navigate beyond the last control for that record on the form.

So, if you want want to avoid going to the next record accidentally, as it were, then I''d suggest two steps :
  1. 而不是在打开表单后导航到所需的记录目前正在进行,最初使用过滤器(或 WhereCondition )打开表单,该过滤器仅指定可以查看的特定记录。无论如何,这通常是一种很好的做法。
  2. Form_BeforeUpdate()事件的事件过程中放入一些代码,将取消设置为 True 除非点击按钮表示操作员选择保存记录。

    这可以通过设置私人变量来确定( blnOK 例如)反映是否可以继续进行。默认情况下,这将始终为 False ,但在按钮后面的代码中,您将在保存之前将其设置为 True 然后 False 之后立即。这样, Form_BeforeUpdate()事件过程将知道它需要允许它。
  1. Instead of navigating to the required record after opening the form as you are doing currently, open the form originally with a filter (or WhereCondition) that specifies only that specific record can be viewed. This is generally good practice anyway.
  2. Put some code in the event procedure for the Form_BeforeUpdate() event that sets Cancel to True unless the button is clicked to indicate the operator chooses to save the record.
    That can be determined by setting up a Private variable (blnOK for instance) to reflect whether it''s ok to proceed or not. By default this would always be False, but in the code behind your button you''d set it to True before the save and then False immediately afterwards. That way the Form_BeforeUpdate() event procedure will know that it needs to allow it.


你有一个事件程序代码的样本吗?我不确定如何表达代码。
DO you have a sample of the event procedure code? I am not sure how to phrase the code.


在其他上。表格属性的标签,将周期设置为当前记录


另一个有用的事情是你可以做一个标签键去控制你不想要它转到是,再次在其他上控件'属性的选项卡将Tab停止设置为否


Phil
On the "Other" tab of form properties, set the Cycle to "Current Record"

Another useful thing that you can do to stop a tab key going to a control you don''t want it to go to is, again on the "Other" tab of the control''s properties to set the Tab Stop to "No"

Phil


这篇关于控制标签键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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