A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Set Focus



 
 
Thread Tools Display Modes
  #1  
Old January 29th, 2009, 07:52 AM posted to microsoft.public.access.gettingstarted
Roger Bell
external usenet poster
 
Posts: 275
Default Set Focus

I have an event procedure (Me.fieldname.setfocus) "After Update" in a field
so that when the user changes the contents, the cursor will remain in the
field. Unfortunately, this does not work, as when the user presses the enter
key, the cursor moves to the next field in the Tab order.

Is there any way one can get the cursor to remain in this field, until
another action is performed?

Thanks for any help
  #2  
Old January 29th, 2009, 01:27 PM posted to microsoft.public.access.gettingstarted
MikeJohnB
external usenet poster
 
Posts: 464
Default Set Focus

One way:

Place an unbound Text Box on your form adjacent to the control you want to
retain focus. set its width property to zero making it not visible to the
user. (Do not set its visible property to No because it must be able to
accept focus)

You will then see your new text box in the Tab Order. Move the text box tab
order to behind the control to retain focus so that it becomes the next
control to accept focus.

In the text box on got focus event, set focus back to the previous control.
Me.PreviousControl.SetFocus

Now whenever the user presses enter, the same control will appear to retain
focus until the user clicks out of the control.

I hope I have explained this well and it helps you???

Kindest Regards
Mike B
--
Advice to Posters.
Check your post for replies or request for more information.
Consider providing some feed back to the response you have recieved.
Kindest Regards Mike B


"Roger Bell" wrote:

I have an event procedure (Me.fieldname.setfocus) "After Update" in a field
so that when the user changes the contents, the cursor will remain in the
field. Unfortunately, this does not work, as when the user presses the enter
key, the cursor moves to the next field in the Tab order.

Is there any way one can get the cursor to remain in this field, until
another action is performed?

Thanks for any help

  #3  
Old January 30th, 2009, 08:04 PM posted to microsoft.public.access.gettingstarted
Linq Adams via AccessMonster.com
external usenet poster
 
Posts: 1,474
Default Set Focus

Actually all you have to do is Setfocus to any other ***existing control***
then set it back to the control in question; you don't need to create a
special textbox for this.

To have the cursor "remain" in the textbox if the value is changed (a strange
requirement, but we each have our own needs!):

Private Sub FirstTextbox_AfterUpdate()
If Me.FirstTextbox Me.FirstTextbox.OldValue Then
AnyOtherTextBox.SetFocus
FirstTextbox.SetFocus
End If
End Sub

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...arted/200901/1

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:57 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.