Date entry with a format

  • Thread starter gmazza via AccessMonster.com
  • Start date
G

gmazza via AccessMonster.com

Hi there,
I have a date field on my form with a Medium format on it, which is dd-mmm-yy.


If I enter 32-Sep-09, because there isn't 32 days in September, it should
error. Instead it switches the day and year and lets me proceed without error,
looking like this:
09-Sep-32

This is not what I want :)

Do I have to code in something behind the scenes or does Access have
something to error on this and NOT switch things up.
I mean whats the point of a format if Access just switches it and allows it??
Thanks for your help!
 
M

Marshall Barton

gmazza said:
I have a date field on my form with a Medium format on it, which is dd-mmm-yy.

If I enter 32-Sep-09, because there isn't 32 days in September, it should
error. Instead it switches the day and year and lets me proceed without error,
looking like this:
09-Sep-32

This is not what I want :)

Do I have to code in something behind the scenes or does Access have
something to error on this and NOT switch things up.
I mean whats the point of a format if Access just switches it and allows it??


That is irritating, but the Format has nothing to do with
it.

About all you can do is use some VBA code in the text box's
BeforeUpdate event procedure to check if the year is out of
an acceptable range. Maybe something like:

If Year(Me.thetextbox) > 2030 Then
MsgBox "Invalid date"
Me.thetextbox.Undo
Cancel = True
End If

If something simple like that is inadequeate for your needs,
you could use the text box's Text property to examine the
characters as entered by the user.
 

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