PC Review


Reply
Thread Tools Rate Thread

Date field - go to first character

 
 
=?Utf-8?B?UmljaGFyZA==?=
Guest
Posts: n/a
 
      3rd Apr 2007
I am using Windows XP and Access 2000. I have a form which has a date field
with an input mask 00/00/0000;0;_

When this field is clicked or tabbed into, I need the cursor to always go to
the first character.

Can this be done?

Many thanks in advance.
--
Richard
 
Reply With Quote
 
 
 
 
=?Utf-8?B?S2VuIFNoZXJpZGFu?=
Guest
Posts: n/a
 
      3rd Apr 2007
Richard:

You can put the following in the control's GotFocus event procedure:

Dim ctrl As Control

Set ctrl = Me.ActiveControl
ctrl.SelLength = 0
ctrl.SelStart = 0

It will work fine if you navigate to the control with the keyboard, but if
you click into the control with the mouse the insertion point will be
wherever in the control you click, not at the start. You could overcome this
by repeating the code in the control's MouseUp event procedure to force the
insertion point back to the start after clicking. However, this would have
the drawback that you could not click into the middle of an existing value in
the control if, for instance, you want to edit it; you'd have to use the
keyboard to move the insertion point from the start position.

Ken Sheridan
Stafford, England

"Richard" wrote:

> I am using Windows XP and Access 2000. I have a form which has a date field
> with an input mask 00/00/0000;0;_
>
> When this field is clicked or tabbed into, I need the cursor to always go to
> the first character.
>
> Can this be done?
>
> Many thanks in advance.
> --
> Richard


 
Reply With Quote
 
=?Utf-8?B?UmljaGFyZA==?=
Guest
Posts: n/a
 
      3rd Apr 2007
Thanks Ken, that is perfect. Exactly what I needed.
--
Richard


"Ken Sheridan" wrote:

> Richard:
>
> You can put the following in the control's GotFocus event procedure:
>
> Dim ctrl As Control
>
> Set ctrl = Me.ActiveControl
> ctrl.SelLength = 0
> ctrl.SelStart = 0
>
> It will work fine if you navigate to the control with the keyboard, but if
> you click into the control with the mouse the insertion point will be
> wherever in the control you click, not at the start. You could overcome this
> by repeating the code in the control's MouseUp event procedure to force the
> insertion point back to the start after clicking. However, this would have
> the drawback that you could not click into the middle of an existing value in
> the control if, for instance, you want to edit it; you'd have to use the
> keyboard to move the insertion point from the start position.
>
> Ken Sheridan
> Stafford, England
>
> "Richard" wrote:
>
> > I am using Windows XP and Access 2000. I have a form which has a date field
> > with an input mask 00/00/0000;0;_
> >
> > When this field is clicked or tabbed into, I need the cursor to always go to
> > the first character.
> >
> > Can this be done?
> >
> > Many thanks in advance.
> > --
> > Richard

>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
6 Character String to Date field =?Utf-8?B?c2NyYXRjaHRyYXg=?= Microsoft Access 6 12th Sep 2007 08:26 PM
Invalid use if 'Null' on date field. Date field intentionally left blank StarfishJoe Microsoft Access Form Coding 2 21st Jun 2005 02:26 AM
replace character in one field with contents of another field Chip Microsoft Access External Data 1 4th Sep 2004 03:39 AM
replace character in field with contents of another field =?Utf-8?B?Q2hpcA==?= Microsoft Access VBA Modules 1 3rd Sep 2004 01:21 AM
Query to create field using first character of another field MarkJH Microsoft Access Queries 0 13th Feb 2004 12:16 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:18 AM.