473,324 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

On Enter key dont want to loose focus

Hi there,

I have a textfield for some search option in the ms access form
I have written a code that after typing the search text as soon as user hits Enter key the data form puts some filter on the table
However focus goes to some other control

I would like the focus to be on the same text box even if the user hits Enter key

my code is
Private Sub txt_Filter_CounterpartyName_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
put_filter
txt_Filter_CounterpartyName.SetFocus
End If
End Sub

Please advice

Yogesh
Mar 20 '08 #1
1 1662
PianoMan64
374 Expert 256MB

Hi there,

I have a textfield for some search option in the ms access form
I have written a code that after typing the search text as soon as user hits Enter key the data form puts some filter on the table
However focus goes to some other control

I would like the focus to be on the same text box even if the user hits Enter key

my code is
Private Sub txt_Filter_CounterpartyName_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
put_filter
txt_Filter_CounterpartyName.SetFocus
End If
End Sub

Please advice

Yogesh
Yogesh,

I'm going to assume for the moment, that the data that you're displaying on the form is a ListControl? and the textfield that you're speaking about is the only field on the form?

If both of those answer are true, then here is what you're going to need to do:

1. Find out what the name of the list control is?
2. Once you find it, Rename it to MyListControl
3. Locate the TextField Control.
3. Rename it to Criteria
4. Create a button control on the form next to Textfield control and call it SearchBtn
5. Right-click on the Button Control and select properties of the list.
6. Scroll down until you get to the event On_Click
7. Press the ... Button on the right side of the dialog box.
8. Select Code Editor
9. type of following code for your list control:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Function SearchBtn_Click()
  3.     Me.MyControlList.RowSourceType = "Table/Query"
  4.     Me.MyControlList.RowSource = "SELECT * FROM {TableName} WHERE {FilterFieldName}='" & Me.Criteria.Value & "'"
  5. 'please name sure to replace {TableName} with the name of the table that you're using and also the {FilterFieldName} with the field name that is in the able that you're searching by.
  6.     Me.MyControlList.Requery
  7.     Me.Repaint
  8. End Function
  9.  
  10.  
Hope that helps,

Joe P.
Mar 20 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Alan Zhong | last post by:
i am trying to similate an "ENTER" as a key to switch focus in a sequence of text inputs. i don't want to use "event.keyCode" since i want to do additional testing before i decide which text input...
3
by: | last post by:
Hi , I did ask before but got no replies. I have a series of textboxes, In Enter event I need to set the focus to a different textbox I am having problems when I set focus within the Textbox...
10
by: mg | last post by:
I want to enter characters in a TextBox in a WebForm, press a Button in the WebForm, and read the characters that were typed into the TextBox from within the Button_Click event handler. The main...
3
by: Philip Townsend | last post by:
I have an aspx page that contains 2 user controls, each containing a seperate textbox and button. I would like to specify that one of the buttons recieve focus when the page loads. Also, I would...
11
by: Sandra Castellanos | last post by:
Hello, I want to know what I have to do to make the enter key to submit forms. I read in another newsgroup that inserting an html hidden text box made the trick, and it actually does, but in my...
2
by: Rocio | last post by:
I have a aspx page, with 2 controls (ascx). Control1 contains a SEARCH button, and textbox to enter the string to search for. Control 2 contains a LOGIN button, and 2 text boxes to enter the...
2
by: chuckdfoster | last post by:
I have a form that with a datagrid with textboxes and a submit button. When the user is in a textbox and they hit enter to try to go to a different line, instead they submit the form before they...
15
by: Adam J. Schaff | last post by:
I have noticed that if a user closes a form via pressing return (either while the OK button has focus or if AcceptButton is set to OK for the form) then the "ENTER" keypress event fires ON THE...
2
by: cvijaykrishna | last post by:
i have a windows based application which contains textboxes when i press enter in one textbox then focus should go to next textbox i dont want to hard code like ex: textbox3.focus but i want to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.