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.Previous Control.Name
Case "cboMyCombo "
cmdMyButton_Cli ck
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 10 3594
john wrote:
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.Previous Control.Name
Case "cboMyCombo "
cmdMyButton_Cli ck
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
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*********@ho tmail.comschree f in bericht
news:JE******** *********@newss vr29.news.prodi gy.net...
john wrote:
>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.Previous Control.Name Case "cboMyCombo " cmdMyButton_Cli ck 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
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.
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 wrote:
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
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
Rick Brandt wrote:
john wrote:
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
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.
In my tests the button ran on the first <Enterpress no matter where I was in
the form and afterwards the button had focus. This was on a form with many
controls. I then built one like yours that had only a TextBox and a Button and
it still worked with a single <Enterpress.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
"Rick Brandt" <ri*********@ho tmail.comschree f in bericht
news:Ir******** **********@news svr21.news.prod igy.com...
Rick Brandt wrote:
>john wrote:
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
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.
In my tests the button ran on the first <Enterpress no matter where I
was in the form and afterwards the button had focus. This was on a form
with many controls. I then built one like yours that had only a TextBox
and a Button and it still worked with a single <Enterpress.
Thanks Rick. I got it working by putting the code in the button's OnFocus
event. Apart from that I can't figure out why the click event is only
triggered when I hit the enter key for the second time, which is different
from what you describe.
john
john wrote:
"Rick Brandt" <ri*********@ho tmail.comschree f in bericht
news:Ir******** **********@news svr21.news.prod igy.com...
Rick Brandt wrote:
john wrote:
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
>
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.
In my tests the button ran on the first <Enterpress no matter
where I was in the form and afterwards the button had focus. This
was on a form with many controls. I then built one like yours that
had only a TextBox and a Button and it still worked with a single
<Enterpress.
Thanks Rick. I got it working by putting the code in the button's
OnFocus event. Apart from that I can't figure out why the click event
is only triggered when I hit the enter key for the second time, which
is different from what you describe.
john
You did set the Default property of the button to True correct? This property
is found on the { Other } tab of the property sheet.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
"Rick Brandt" <ri*********@ho tmail.comschree f in bericht
news:cc******** **********@news svr21.news.prod igy.com...
john wrote:
>"Rick Brandt" <ri*********@ho tmail.comschree f in bericht news:Ir******* ***********@new ssvr21.news.pro digy.com...
Rick Brandt wrote:
john wrote:
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
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.
In my tests the button ran on the first <Enterpress no matter
where I was in the form and afterwards the button had focus. This
was on a form with many controls. I then built one like yours that
had only a TextBox and a Button and it still worked with a single
<Enterpress.
Thanks Rick. I got it working by putting the code in the button's OnFocus event. Apart from that I can't figure out why the click event is only triggered when I hit the enter key for the second time, which is different from what you describe. john
You did set the Default property of the button to True correct? This
property is found on the { Other } tab of the property sheet.
Sorry. I was so sure it was set to True but I must have switched it back to
False while testing. Now it's working like you described.
Thanks for your time...
john
have you tried just running the Find code directly from the "search"
control's AfterUpdate event procedure?
hth
"john" <jo**@test.comw rote in message
news:f_******** *************** *******@casema. nl...
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.Previous Control.Name
Case "cboMyCombo "
cmdMyButton_Cli ck
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
Thanks, that works, but when user enters a wrong number and hits enter the
focus goes to the next field while I would like it to remain focused on the
search field. The same accounts for when a user doesn't update the field and
hits enter.
john
tina" <no****@address .comschreef in bericht
news:61******** ***********@bgt nsc04-news.ops.worldn et.att.net...
have you tried just running the Find code directly from the "search"
control's AfterUpdate event procedure?
hth
"john" <jo**@test.comw rote in message
news:f_******** *************** *******@casema. nl...
>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.Previous Control.Name Case "cboMyCombo " cmdMyButton_Cli ck 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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: nkp |
last post by:
Sorry guys, basic questions.....
1)how do you prevent negative numeric input in a text box (-2345 etc)
2)how do detect /prevent input of LESS than 8 characters in a text box(
where a password must be a minimum of 8 characters for example)
Thank you.
|
by: Fred Sawtelle |
last post by:
I'm trying to trap the Enter key in any of the key events
(keypress, keydown, keyup) of the Windows .Net combobox
control. Try as I might, I cannot get the event to
respond to an Enter key press; nor can I find anything
documenting this situation. Help is appreciated.
Here's my code. This pops up a messagebox for normal
alphanumeric keys, but does nothing at all when Enter is
pressed.
|
by: Bob Darlington |
last post by:
When a user clears a value from a combo box (by pressing the delete key),
the following message appears:
"You tried to assign the null value to a variable that is not a variant data
type".
The problem is that I can't trap the error in the Before Update event. The
error is generated before it gets there. Furthermore, I am not trying to
assign the value to any 'variable' (at least not till the AfterUpdate event)
|
by: MLH |
last post by:
I get error 3315 when attempting to enter ZLS into
a text-type table field whose allow zls property is set
to false. The error says "Field MyTable.MyField can't
be a zero-length string"
For sure, this is what I expected, entering into a table.
The same 3315 error occurs if you try to enter "" into
a bound textbox control on a form (bound to the same
field. I expected that too.
|
by: Brian |
last post by:
I want to trap the pressing of the enter key from a datagrid cell. I'm able
to get other characters trapped but not the enter key. Does anyone have a
code sample of this?
Thanks
| |
by: David McDivitt |
last post by:
Another fellow here must modify an application. On the web page, pressing
the enter key causes the form to submit. What users want is to remove enter
key functionality from within a textarea and cause the enter key to submit
the form, AND cause the F6 key to do what the enter key used to do inside
the text area. The idea I suggested is to trap keystrokes in the text area,
If the enter key is pressed, do the submit method. If F6 is pressed,...
|
by: Rich |
last post by:
Hello,
I need to trap/detect when a textbox is entered via the tabkey. If the
textbox is not empty when entered via the tabkey then set focus to next
textbox. To enter that textbox would then require a mouseclick if it already
contains text to be edited. I am guessing that I would need to trap for
this in the Enter Event of this particular textbox.
I tried this in the Enter Event of the Textbox, but...
|
by: Zytan |
last post by:
Hello everyone,
I would like to trap the ENTER key press in a RichTextBox, when it is
in focus. I have an Accept Button set, which grabs it. In Win32, I
could use the WM_GETDLGCODE Notification to accomplish this, but I am
unsure where that functionality exists in VB .NET. Handling the
KeyPress event doesn't work, as it doesn't even get a chance to be run
-- the Accept Button grabs it first.
Any sources of information would be...
|
by: =?Utf-8?B?RyBIdXN0aXM=?= |
last post by:
This is the 2nd time posting so sorry for duplications.
I am using VB.NT 2005 & a standard Combobox.
I've been wracking my brain over this problem for a over a month & cannot
seem to find a way to trap the pressing of a Tab Key when the focus is in a
Combobox. The KeyDown or KeyUp event for a combobox will not fire when the
tab key is pressed. The Keyup event will fire when the Tab key is used to tab
into the combo, however I want to trap...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |