【译文】如何防止在窗体上移动时意外清除数据
时 间:2013-07-30 09:10:20
作 者:周芳 ID:24526 城市:上海
摘 要:某个控件会整体选定(例如:1234AAA),导致不小心按个键就会全清掉,如果一获得焦点并放在首位(放在1的前面)就可避免这情况
正 文:
来自:微软 翻译:周芳
【译文】如何防止在窗体上移动时意外清除数据
当你的选项卡从一个文本框或备注字段到另一个形式,突出显示文本控制。这很容易让用户通过按一个键而不小心删除文本。通过几行代码,您可以将插入点放到文本框中第一的位置上,把意外删除文本的风险减小到最小化。
为此,给文本框的GotFocus事件创建一个程序。在GotFocus事件过程中,设置文本框的SelLength属性。 下面的例子说明了如何为一个取名为txtFirstName的文本框做这个功能。
VBA代码如下:
Private Sub txtFirstName_GotFocus()
Me.txtFirstName.SelLength = Me.txtFirstName.SelStart
End Sub
原文:How to: Prevent the Accidental Erasure of Data When Moving Between Controls on a Form
When you tab from one text box or memo field to another in a form, the text in the control is highlighted. This makes it easy for users to accidentally delete the text by pressing a key. By using a few lines of code, you can move the insertion point to the first position in the text box, minimizing the risk of accidentally deleting the text.
To do this, create a procedure for the text box's GotFocus event. In the GotFocus event procedure, set the SelLength property of the text box to its SelStart property. The following example illustrates how to do this for a text box named txtFirstName.
VBA:
Private Sub txtFirstName_GotFocus()
Me.txtFirstName.SelLength = Me.txtFirstName.SelStart
End Sub
Access软件网QQ交流群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- Access制作的RGB调色板...(09.15)
- Access制作的快速车牌输入...(09.13)
- 【Access高效办公】统计当...(06.30)
- 【Access高效办公】用复选...(06.24)
- 根据变化的日期来自动编号的示例...(06.20)
- 【Access高效办公】按日期...(06.12)
- 合并列数据到一个文本框的示例;...(05.06)
- 通过命令按钮让Access列表...(04.24)
- 【Access高效办公】统计当...(03.11)

学习心得
最新文章
- 关于重装系统后Access开发的软...(09.17)
- Access制作的RGB调色板示例(09.15)
- Access制作的快速车牌输入改进...(09.13)
- Access颜色编号管理数据库--...(09.10)
- 分享一个Access报表最后一页始...(09.03)
- 64位操作系统引用DAO出现加载D...(08.26)
- Access设置试用期截止日期默认...(08.15)
- Access快速开发平台--Err...(08.12)
- Deepseek资料整理神器(08.11)
- 【Access财务分析示例】按月统...(08.08)