473,387 Members | 1,532 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,387 software developers and data experts.

Not leaving text box

I use Access 2003 on WinXP.

I use a text box to search for a member id. When it finds it, the
record pointer moves and the new record is displayed and the text box
is selected for me to type in a new id. That is OK.

When the id is not found, when I press Enter the next text box in the
tab order gets the focus. That is not OK. How do I let the current
text box keep the focus so I can type in a new id?

Private Sub txtSearch_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[MemberID] = " & Str(Nz(Me![txtSearch], 0))
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
End If
End Sub

Regards,

Jan Nordgreen

--
My sites:
sharealink (favourite links) -
http://simpler-solutions.net/shareal..._main.php?id=1
jan's diary - http://simpler-solutions.net/pmachinefree/weblog.php
think again (seductive math problems for the modern mind) -
http://simpler-solutions.net/pmachin...thinkagain.php
mumnet (mathematical ulterior motives) - http://mumnet.tripod.com
free learning of mathematics (free online journal) -
http://simpler-solutions.net/pmachin...om.php?id=P206
modern times (tools for better schools) -
http://simpler-solutions.net/pmachin...oderntimes.php
miscajitas - http://miscajitas.tripod.com
photos from the Dominican Republic - http://janparasiempre.tripod.com
photos from Grand Cayman - http://janandcayman.tripod.com
simpler solutions (educational software) -
http://simpler-solutions.net
freedom to learn (resources for learning) -
http://freedomtolearn.tripod.com
http://jansgames0.tripod.com
http://janscv.tripod.com
Nov 13 '05 #1
6 1486
Put your search text box into the Form Header section.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Jan Nordgreen" <ja**********@gmail.com> wrote in message
news:36**************************@posting.google.c om...
I use Access 2003 on WinXP.

I use a text box to search for a member id. When it finds it, the
record pointer moves and the new record is displayed and the text box
is selected for me to type in a new id. That is OK.

When the id is not found, when I press Enter the next text box in the
tab order gets the focus. That is not OK. How do I let the current
text box keep the focus so I can type in a new id?

Private Sub txtSearch_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[MemberID] = " & Str(Nz(Me![txtSearch], 0))
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
End If
End Sub

Nov 13 '05 #2
Thank you for your answer.

I tried it. As far as I can see the only effect it had was that the
AfterUpdate code didn't run, so it didn't solve my problem.

Regards,

Jan Nordgreen
Nov 13 '05 #3
ja**********@gmail.com (Jan Nordgreen) wrote in message news:<36**************************@posting.google. com>...
I use Access 2003 on WinXP.

I use a text box to search for a member id. When it finds it, the
record pointer moves and the new record is displayed and the text box
is selected for me to type in a new id. That is OK.

When the id is not found, when I press Enter the next text box in the
tab order gets the focus. That is not OK. How do I let the current
text box keep the focus so I can type in a new id?

Private Sub txtSearch_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[MemberID] = " & Str(Nz(Me![txtSearch], 0))
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
End If
End Sub

Regards,

Jan Nordgreen


You can always set the focus at the end of this sub back to the text
box you use for searching.

Me![txtSearch].SetFocus
Nov 13 '05 #4
By default, Access cycles through the controls in the section. If the text
box is the only one in the Form Header section, then the focus stays in that
box - unless you programmatically move it elsewhere or something else forces
a change of focus.

If the code did not run, right-click the control in design view, and choose
Properties. Chances are the:
[Event Procedure]
needs to be restored to the After Update property after you moved the
control to a different section.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Jan Nordgreen" <ja**********@gmail.com> wrote in message
news:36**************************@posting.google.c om...
Thank you for your answer.

I tried it. As far as I can see the only effect it had was that the
AfterUpdate code didn't run, so it didn't solve my problem.

Regards,

Jan Nordgreen

Nov 13 '05 #5
You were right. I had to reassign it and then it worked like a dream,
i.e. as you described. :)

Thanks for educating me!
Nov 13 '05 #6
To add the setfocus instruction at the end of the afterupdate method
did not change anything. When the record is not found the focus is
given to the next control.
Nov 13 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: delerious | last post by:
I have a DIV that contains some anchors arranged vertically. On the DIV element I have an onmouseout event handler. If I move the mouse over one of the anchors, and then move it to another anchor...
3
by: Peter J Ross | last post by:
Greetings. I'm quite new to PHP and have very little knowledge of programming in general, so I may be missing something obvious, but I can't find a solution to the following difficulty in either...
2
by: Kevin Blount | last post by:
I have a string of HTML (used for a specific purpose) that I'd like to use somewhere else but as plain text. Rather than introduce a specifically created plain text version I'd like to strip the...
9
by: Matt | last post by:
In many places in my application, I have a DataGridView which users can either enter data into or use as a method of navigation in a master/detail form view. I need a method of stopping the user...
5
by: RSL101 | last post by:
Dear DBAs. I am wondering if anyone gotten good results leaving the, Monitor health of instance and databases (HEALTH_MON) = ON I find the default ON setting causes more problem than its...
18
by: sebastian | last post by:
Can this be done without client-side scripting? I thought sessions might be the answer but after some testing found that sometimes the old session data remained even after the user left the site...
3
by: vp.softverm | last post by:
hi all., Am doing cross browser compatibility, in IE at one page when i click on the reference text to call a perticular fuction its calling but leaving a huge blank space at the top of the...
1
by: Anonymous | last post by:
Which is the correct approach to disable buttons when leaving an aspnet page? Currently I have the following html, which disables buttons when pressing F5 in FireFox, which ofcourse can occur...
8
by: jehugaleahsa | last post by:
Hello: We wrote an entire application where we add our DataRows to our DataTables immediately. However, we have to shut off our constraints to do this. We would like to use detached DataRows to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
jinu1996
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...

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.