Need current year

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello there! Using A02 on XP. Been playing with this but can't get it to
work. I know I'm missing something basic such as WHERE it is best to even do
this. Here goes: I'm using mm/dd/yyyy as my basic date format in tables:
99/99/0000;0;_ I would really like to have the table's input mask be
99/99/2005;0;_ (I can do 99/99/"2005";0;_ but what I REALLY need is 2005 to
be the current year.) I'd like the user to see this input mask on whatever
form I use the field on: __/__/2005 and when they type mm and dd they can
press enter and the whole date is in the field.

Is the input mask of the table the best place to do this? Figured once
rather than on each form was best but understand that sometimes table level
is not best.

Thanks in advance for any help or advice on this!!!

Bonnie
 
You need to set the input mask dynamically.
On the "on open" event of the form, include the following

Me.Title.InputMask = "99/99/" & Chr(34) & CStr(DatePart("YYYY", Now)) &
Chr(34) & ";0;_"

chr(34) is " so this is just how I get it to put the quotes in the string.
This comes out as 99/99/"2005";0;_ which I think is what you wanted.

PS flattery will get you everywhere!
 
Bonnie,
"2005" isn't a valid input mask. Therefore it needs to think it's a string.
When I use this, it still works ok on my example with the double quotes in -
my form and tables treat it as a date perfectly ok.

Why do you need to remove the " from it?
 
Hello there! Using A02 on XP. Been playing with this but can't get it to
work. I know I'm missing something basic such as WHERE it is best to even do
this. Here goes: I'm using mm/dd/yyyy as my basic date format in tables:
99/99/0000;0;_ I would really like to have the table's input mask be
99/99/2005;0;_ (I can do 99/99/"2005";0;_ but what I REALLY need is 2005 to
be the current year.) I'd like the user to see this input mask on whatever
form I use the field on: __/__/2005 and when they type mm and dd they can
press enter and the whole date is in the field.

Is the input mask of the table the best place to do this? Figured once
rather than on each form was best but understand that sometimes table level
is not best.

Thanks in advance for any help or advice on this!!!

Bonnie

Don't use a mask.
Without a mask, if you enter the month and day of a date, Access will
assume the current year, so if you enter 7/16 Access will store and
display 7/16/2005, or whatever the current year is.
 
Sorry, misunderstood again. Tried it as you provided and all is well.

Thanks VERY much for your help!
 
Jack,

Thanks BUNCHES for the quick response. Exactly (except for the quotes
around 2005, my boo-boo) what I needed. Tried to remove the Char34s but my
stuff doesn't work.

I get: "= "99/99/\ C"Str(D"a"teP"a"rt(YYYY"," Now))";0;_

Help???

Thanks again and sorry for the bad communication. I should have been clearer.

Crossing my fingers that you are still out there...
 
Bonnie:
I think I've finally grasped what you're trying to do. You want an input
mask so it looks like this to the user:

__/__/2005

but allow them to overtype the 2005 if they want. I don't think this is
possible.

What you might be better off with is an input mask of 09/09/9999

which would look like this __/__/_____.

as fred says, if you don't specify the year, it defaults to the current
year. Another option would be to hold it in three separate text fields
"month" "day" "year" ... and set the after update for each to string them
together to make a date.

Although to be honest, I think you'd be making it overcomplicated here. I
think you should either just go for the __/__/____ input mask, or don't use
an input mask.

If there's anyone out there who knows how to put default (and overtypable)
values in an access input mask however, I'd like to know as well, as it would
be most useful. Unfortunately based on the characters the input mask allows,
I don't think we can do it...
 
Didn't know about the defaulting feature so have always used that input mask.
I am going to print out the info from yourself and Fred and create a little
test table. I may have some editing to do on my table's input masks for these
dates.

I do need the four digit year but would love to allow for fewer keystrokes.

Thanks very much for explaining it. I generally do overcomplicate things
but LOVE to find shorter ways. When the lightbulb comes on, it is a good
thing and the light is welcomed.

LUV U GUYS!!!
 
Back
Top