Date/Time field

G

Guest

I though this would be a simple fix, but I am stuck. I have a date/time text
box that is used to filter with. There is a format mask of 00/00/0000; My
problem is that when the text box is clicked on, if the cursor is in the
middle of the format mask that is where you start typing, so if you want to
start from the beginning you have to backspace to the start. I would like
the on click event to start as far left as possible so that there is no need
to backspace to get tot the beginning. Thanks for the help.
 
S

Stuart McCall

Ryan Tisserand said:
I though this would be a simple fix, but I am stuck. I have a date/time
text
box that is used to filter with. There is a format mask of 00/00/0000;
My
problem is that when the text box is clicked on, if the cursor is in the
middle of the format mask that is where you start typing, so if you want
to
start from the beginning you have to backspace to the start. I would like
the on click event to start as far left as possible so that there is no
need
to backspace to get tot the beginning. Thanks for the help.

Type the following into the textbox's OnEnter event procedure:

Textbox.SelStart = 0

(substitute the real textbox's name of course)
 
G

Guest

Please forgive me, but it is a combo box, not a text box.
DateFilter.selstart=0 is not working. Is the code differant for a combo box?
 
S

Stuart McCall

Ryan Tisserand said:
Please forgive me, but it is a combo box, not a text box.
DateFilter.selstart=0 is not working. Is the code differant for a combo
box?

The code is no different, because an Access combo is actually a marriage of
a textbox with a listbox. I just tested it here (A2003) and it works fine.

When you say "DateFilter.selstart=0 is not working" what do you mean? What
symptoms are you getting?

Did you try the code in the combo's Enter event as I specified? I ask this
because the control must have the focus for this to work...
 
G

Guest

Yes, I did use the on enter event to place the code. The result that I am
getting is the same result before i put in the code. When I click on the
combo box the cursor shows up wherever I click, not at the start of the short
date format mask that I have set up for that field. Your code makes since,
but for some reason I still have to back up to the start to begin tying from
the start. One more time, for spacific detail, this is a combo box,
date/time, date/time format mask field with the on enter event set to
DateFilter.SelStart = 0.
 
S

Stuart McCall

Ryan Tisserand said:
Yes, I did use the on enter event to place the code. The result that I am
getting is the same result before i put in the code. When I click on the
combo box the cursor shows up wherever I click, not at the start of the
short
date format mask that I have set up for that field. Your code makes
since,
but for some reason I still have to back up to the start to begin tying
from
the start. One more time, for spacific detail, this is a combo box,
date/time, date/time format mask field with the on enter event set to
DateFilter.SelStart = 0.

Ok I finally noticed you were specifying clicking into the control (duh!).
When I tested this I was tabbing into the combo, in which case the code does
what its supposed to. So leave the code in the Enter procedure (so users can
use keyboard if they want to) and put the following in the combo's MouseDown
procedure:

DoCmd.CancelEvent
DateFilter.SelStart = 0
 
J

John W. Vinson

Ok I finally noticed you were specifying clicking into the control (duh!).
When I tested this I was tabbing into the combo, in which case the code does
what its supposed to. So leave the code in the Enter procedure (so users can
use keyboard if they want to) and put the following in the combo's MouseDown
procedure:

DoCmd.CancelEvent
DateFilter.SelStart = 0

Stuart, wouldn't the GotFocus event serve both cases?

John W. Vinson [MVP]
 
S

Stuart McCall

John W. Vinson said:
Stuart, wouldn't the GotFocus event serve both cases?

John W. Vinson [MVP]

Unfortunately not, because you have to "throw away" the mouse event (using
CancelEvent).
There's some kind of interaction between a mouse click and an input mask
(shrug). Anyhoo, by cancelling the event, Access executes the code just as
if the user tabbed into the control.
 
J

John W. Vinson

Unfortunately not, because you have to "throw away" the mouse event (using
CancelEvent).
There's some kind of interaction between a mouse click and an input mask
(shrug). Anyhoo, by cancelling the event, Access executes the code just as
if the user tabbed into the control.

Thanks - I'd had odd things happen when I tried something like this, and
wasn't aware of that interaction.

John W. Vinson [MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top