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 » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Cursor position



 
 
Thread Tools Display Modes
  #1  
Old January 11th, 2010, 10:04 PM posted to microsoft.public.access.forms
Abe Katz
external usenet poster
 
Posts: 43
Default Cursor position

Hello,
When I tab from one control to another or use docmd.gotoControl the control
gets highlighted automatically.
Is there a way to put the cursor at the end of the control or at the
beginning of the control without highlighting the control?
Thanks
Abe


  #2  
Old January 11th, 2010, 10:37 PM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Cursor position

On Mon, 11 Jan 2010 16:04:58 -0500, "Abe Katz" wrote:

Hello,
When I tab from one control to another or use docmd.gotoControl the control
gets highlighted automatically.
Is there a way to put the cursor at the end of the control or at the
beginning of the control without highlighting the control?
Thanks
Abe


Take a look at the SelStart and SelLen properties:

Me!controlname.SelStart = Len(Me!controlname)
Me!controlname.SelLen = 0

will put the cursor at the end, with nothing selected.

It might need to be Len(...) + 1, I haven't used it in a while!
--

John W. Vinson [MVP]
  #3  
Old January 11th, 2010, 11:01 PM posted to microsoft.public.access.forms
Al Campagna[_2_]
external usenet poster
 
Posts: 1,462
Default Cursor position

Abe,
There are two situations...
When you Tab into the field, or when you mouse click
into the field. (ex. LastName)
This code covers both...
**For cursor at the Beginning of the text string...
Private Sub LastName_Click()
LastName.SelStart = 0
LastName.SelLength = 0
End Sub
Private Sub LastName_Enter()
LastName.SelStart = 0
LastName.SelLength = 0
End Sub

**For Cursor at End of the text string...
Private Sub LastName_Click()
LastName.SelStart = Len(LastName)
LastName.SelLength = 0
End Sub
Private Sub LastName_Enter()
LastName.SelStart = Len(LastName)
LastName.SelLength = 0
End Sub
--
hth
Al Campagna
Microsoft Access MVP 2006-2009
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

"Abe Katz" wrote in message
...
Hello,
When I tab from one control to another or use docmd.gotoControl the
control gets highlighted automatically.
Is there a way to put the cursor at the end of the control or at the
beginning of the control without highlighting the control?
Thanks
Abe



  #4  
Old January 12th, 2010, 01:49 AM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Cursor position

On Mon, 11 Jan 2010 17:01:27 -0500, "Al Campagna"
wrote:

When you Tab into the field, or when you mouse click
into the field. (ex. LastName)


Hrm. I just use GotFocus() to cover both these cases. I can see that you might
want to distinguish them though...
--

John W. Vinson [MVP]
  #5  
Old January 12th, 2010, 03:54 AM posted to microsoft.public.access.forms
Al Campagna[_2_]
external usenet poster
 
Posts: 1,462
Default Cursor position

John,
Oh you know me... I always rely on "brute force" in my coding.
:-D
Al

"John W. Vinson" wrote in message
...
On Mon, 11 Jan 2010 17:01:27 -0500, "Al Campagna"
wrote:

When you Tab into the field, or when you mouse click
into the field. (ex. LastName)


Hrm. I just use GotFocus() to cover both these cases. I can see that you
might
want to distinguish them though...
--

John W. Vinson [MVP]



  #6  
Old January 12th, 2010, 04:39 AM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Cursor position

On Mon, 11 Jan 2010 21:54:11 -0500, "Al Campagna"
wrote:

John,
Oh you know me... I always rely on "brute force" in my coding.
:-D
Al


A programmer who lived in Racine
Said, "I can overload any machine -
My secret's aversion
To loops and recursion:
Just acres of in-line routine!"
--

John W. Vinson [MVP]
  #7  
Old January 12th, 2010, 12:17 PM posted to microsoft.public.access.forms
Al Campagna[_2_]
external usenet poster
 
Posts: 1,462
Default Cursor position

Good one!

And, OT... but one of my favorites...

"Even fleas have little fleas upon their backs to bite 'em.
And little fleas have littler fleas... and so on... ad infinitum."

Al

"John W. Vinson" wrote in message
...
On Mon, 11 Jan 2010 21:54:11 -0500, "Al Campagna"
wrote:

John,
Oh you know me... I always rely on "brute force" in my coding.
:-D
Al


A programmer who lived in Racine
Said, "I can overload any machine -
My secret's aversion
To loops and recursion:
Just acres of in-line routine!"
--

John W. Vinson [MVP]



  #8  
Old January 12th, 2010, 04:56 PM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Cursor position

On Tue, 12 Jan 2010 06:17:41 -0500, "Al Campagna"
wrote:

Good one!

And, OT... but one of my favorites...

"Even fleas have little fleas upon their backs to bite 'em.
And little fleas have littler fleas... and so on... ad infinitum."


to which a physicist replied...

Great vortices have lesser ones
that feed on their velocity;
The lesser ones have lesser ones
and so on, to viscosity.
--

John W. Vinson [MVP]
  #9  
Old January 12th, 2010, 08:05 PM posted to microsoft.public.access.forms
Al Campagna[_2_]
external usenet poster
 
Posts: 1,462
Default Cursor position

Ha... a keeper!
Al

"John W. Vinson" wrote in message
...
On Tue, 12 Jan 2010 06:17:41 -0500, "Al Campagna"
wrote:

Good one!

And, OT... but one of my favorites...

"Even fleas have little fleas upon their backs to bite 'em.
And little fleas have littler fleas... and so on... ad infinitum."


to which a physicist replied...

Great vortices have lesser ones
that feed on their velocity;
The lesser ones have lesser ones
and so on, to viscosity.
--

John W. Vinson [MVP]



 




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 06:35 AM.


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