进入的陷阱...... [英] Trap for enter...

查看:101
本文介绍了进入的陷阱......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一种形式中,我试图让搜索字段能够快速找到ID号上的

记录。用户输入一个数字并按Enter键移动到

记录。如何陷入输入击键,我应该把

代码放在哪里?

我发现这个:

你可以设置表格将KeyPreview属性改为YES,然后在Form'的
KeyPress事件中,添加以下伪代码:

Select Case KeyAscii

案例13

Select Case Screen.PreviousControl.Name

Case" cboMyCombo"

cmdMyButton_Click

End选择

结束选择

但是我想知道是否有办法在搜索字段内编码这个?

另外,如果我必须使用上面的代码在哪里可以找到KeyPreview

属性?

提前致谢,

john

In a form I''m trying to make a search field to be able to quickly find a
record on ID-number. User enters a number and presses enter to move to that
record. How do I trap for the enter-keystroke and where should I put the
code?
I found this:
You can set the form''s KeyPreview property to YES, then in the Form''s
KeyPress event, add the following pseudo-code:
Select Case KeyAscii
Case 13
Select Case Screen.PreviousControl.Name
Case "cboMyCombo"
cmdMyButton_Click
End Select
End Select
but I wondered if there is a way to code this inside of the searchfield?
Also, if I have to use the above code where can I find the KeyPreview
property?
Thanks in advance,
john

推荐答案

john写道:
john wrote:

在一个表格中我试图使搜索字段能够快速

找到ID号的记录。用户输入一个数字然后按回车键

移动到该记录。如何陷入输入键击以及

我应该放置代码?

我发现这个:

你可以设置表格将KeyPreview属性改为YES,然后在Form'的
KeyPress事件中,添加以下伪代码:

Select Case KeyAscii

案例13

Select Case Screen.PreviousControl.Name

Case" cboMyCombo"

cmdMyButton_Click

End选择

结束选择


但是我想知道是否有办法在

搜索字段内编码?另外,如果我必须使用上面的代码,我在哪里可以找到

的KeyPreview属性?

提前致谢,

john
In a form I''m trying to make a search field to be able to quickly
find a record on ID-number. User enters a number and presses enter to
move to that record. How do I trap for the enter-keystroke and where
should I put the code?
I found this:
You can set the form''s KeyPreview property to YES, then in the Form''s
KeyPress event, add the following pseudo-code:
Select Case KeyAscii
Case 13
Select Case Screen.PreviousControl.Name
Case "cboMyCombo"
cmdMyButton_Click
End Select
End Select
but I wondered if there is a way to code this inside of the
searchfield? Also, if I have to use the above code where can I find
the KeyPreview property?
Thanks in advance,
john



将代码放在按钮的单击事件中,并将

按钮的Default属性设置为true。当您按

< Enter>时,这将使按钮的click事件运行。你可以让按钮变得透明,如果你不希望它是可见的。


-

Rick Brandt ,Microsoft Access MVP

电子邮件(视情况而定)至...

在Hunter dot的RBrandt

Put your code in the click event of a button and set the Default property of the
button to true. That will make the click event of the button run when you press
<Enter>. You can make the button transparent if you don''t want it to be
visible.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


" ; Rick Brandt" < ri ********* @ hotmail.comschreef in bericht

news:JE ***************** @ newssvr29.news .prodigy.ne t ...
"Rick Brandt" <ri*********@hotmail.comschreef in bericht
news:JE*****************@newssvr29.news.prodigy.ne t...

john写道:
john wrote:

>在表格I'中我试图让搜索字段能够快速找到ID号上的记录。用户输入一个数字并按回车键移动到该记录。如何陷入enter-keystroke以及我应该把代码放在哪里?
我发现了这个:
你可以将表单''的KeyPreview属性设置为YES,然后在表单中在KeyPress活动中,添加以下伪代码:
选择Case KeyAscii
案例13
选择案例Screen.PreviousControl.Name
案例cboMyCombo
cmdMyButton_Click
结束选择
结束选择

但是我想知道是否有办法在
搜索字段内编码?另外,如果我必须使用上面的代码,我在哪里可以找到KeyPreview属性?
提前致谢,
john
>In a form I''m trying to make a search field to be able to quickly
find a record on ID-number. User enters a number and presses enter to
move to that record. How do I trap for the enter-keystroke and where
should I put the code?
I found this:
You can set the form''s KeyPreview property to YES, then in the Form''s
KeyPress event, add the following pseudo-code:
Select Case KeyAscii
Case 13
Select Case Screen.PreviousControl.Name
Case "cboMyCombo"
cmdMyButton_Click
End Select
End Select
but I wondered if there is a way to code this inside of the
searchfield? Also, if I have to use the above code where can I find
the KeyPreview property?
Thanks in advance,
john



将代码放在按钮的单击事件中,并将按钮的默认属性

设置为true。当按下< Enter>时,这将使按钮的click事件运行

。如果你没有b $ b希望它可见,你可以使按钮透明。


Put your code in the click event of a button and set the Default property
of the button to true. That will make the click event of the button run
when you press <Enter>. You can make the button transparent if you don''t
want it to be visible.



谢谢里克。我部分得到了它的工作。输入被''识别''但是我有

按两次输入来执行按钮。第一次进入按钮

获得焦点(来自搜索字段)并且第二次输入

按钮实际上是按下的。有什么想法解决这个问题吗?

john

Thanks Rick. I partly got it working. The enter is ''recognized'' but I have
to press enter twice to execute the button. With the first enter the button
gets focus (coming from the searchfield) and with the second enter the
button is actually pressed. Any idea to resolve that?
john


john写道:
john wrote:

谢谢里克。我部分得到了它的工作。输入被识别,但是我必须按两次输入才能执行按钮。随着第一个输入

按钮获得焦点(来自搜索字段)并且按

秒输入实际按下按钮。有什么想法解决这个问题吗?

john
Thanks Rick. I partly got it working. The enter is ''recognized'' but I
have to press enter twice to execute the button. With the first enter
the button gets focus (coming from the searchfield) and with the
second enter the button is actually pressed. Any idea to resolve that?
john



然后你还有问题。

按钮具有焦点时,< Enterkey将运行任何按钮。默认属性的重点是通过按< Enter>来从表单中的任何位置运行

按钮。


我将运行一些测试和回发。


-

Rick Brandt,Microsoft Access MVP

电子邮件(视情况而定)至。 ..

在Hunter dot com的RBrandt

Then you still have something wrong. The <Enterkey will run ANY button when
that button has focus. The whole point of the Default property is to make a
button run from anywhere in the form by pressing <Enter>.

I''ll run a few tests and post back.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


这篇关于进入的陷阱......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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