Partial Date input ?

Bomac

Registered User.
Local time
Today, 05:17
Joined
Nov 4, 2007
Messages
20
Hello All,

I have a minor question about inputting a date on a form. The dates we are inputting are for events which will take place during March next year.

Is it possible to have the system supply a specific year when the dd/mm is input. i.e. when the user comes to input the date they type in 2/3/ then ‘tab’ to move to the next field. I always want the system to supply the year 2008 so that the date entered in the database would be 02/03/2008. I am aware that if you type in 2/3/08 the system will automatically convert it to 02/03/2008.

There are probably several ways to overcome this little problem but just having a default year would be a great time saver. The User may have to type in the date approximately 500 times.

I’d be grateful for any helpful hints.

Bomac
 
not to my knowledge, but it is possible to create your own masks
Hello All,

I have a minor question about inputting a date on a form. The dates we are inputting are for events which will take place during March next year.

Is it possible to have the system supply a specific year when the dd/mm is input. i.e. when the user comes to input the date they type in 2/3/ then ‘tab’ to move to the next field. I always want the system to supply the year 2008 so that the date entered in the database would be 02/03/2008. I am aware that if you type in 2/3/08 the system will automatically convert it to 02/03/2008.

There are probably several ways to overcome this little problem but just having a default year would be a great time saver. The User may have to type in the date approximately 500 times.

I’d be grateful for any helpful hints.

Bomac
 
Last edited:
Partial Date Input

Hello Harleyskater,

I have been trying to get something using masks etc to work but so far I've had no joy. It always seems to interfere with the rest of the field.

It was just a thought but if it can't be done we'll just keep on typing. Thanks anyway.

Bomac
 
Well, here you go this should give you what you want and it will change the year to whatever the current year is (put this code in the form's On Load event):
Code:
Me.YourTexBoxNameHere.InputMask = "99/99/\" & Left(Year(Date), 1) & "\" & Mid(Year(Date), 2, 1) & "\" & Mid(Year(Date), 3, 1) & "\" & Right(Year(Date), 1) & ";0;_"
 
Partial Date Input

Thanks Boblarson,

I will take that away and have a try. When you say it will change the year to whatever the current year is - can I make it change the year to next year ?

Bomac
 
Do you always want it to be next year. So, in 2008 it should be 2009?
 
Hello Boblarson,

This particular date gets set now in readiness for an event which always takes place the following March so the date will always be current+1.

Bomac
 
Then change it to:

Code:
Me.YourTextBoxNameHere.InputMask = "99/99/\" & Left(Year(Date), 1) & "\" & Mid(Year(Date), 2, 1) & "\" & Mid(Year(DateAdd("yyyy", 1, Date)), 3, 1) & "\" & Right(Year(DateAdd("yyyy", 1, Date)), 1) & ";0;_"

I didn't apply the DateAdd to the first two digits because your database is not likely going to be in use in 2100.
 
Thanks Boblarson,

I think I can even understand enough to see the difference between the first and second statement ! By the way you are so right in your assumption...I'll settle for 2010 when I can retire (for a second time!) from active service.

Thank you for your help,
Bomac
 
Hello Boblarson,

Sorry to have to come back - especially since it's most likely my lack of understanding that's to blame but - I get the following error message when I try to open the form:-

Access can't find the macro 'Me'.
"The macro (or its macro group) doesn't exist, or the macro is new but hasn't been saved."

I copied and pasted the coding to the form's 'On Load', saved the changes and got the error message when I tried to open the form.

What haven't I done or what have I missed?

Bomac
 
Spot-on Boblarson!

I had put it in the wrong place ! However now that it's in the correct place the error message has changed:-

Run-time error '2465'
Acces can't find the field 'l' referred to in your expression. (where the 'l' is the vertical line and not the lower case letter L)

I am sorry to be so dumb.
Bomac
 
Hello Boblarson,

That was wierd! I cut and pasted the code you supplied, knowing I would probably mess it up if I tried to copy it, and somewhere in the process the code acquired square brackets round a couple of the words. I removed these after revisiting and checking your previous replies and bingo - all is well and works just fine.

I am most grateful for your patience and help.

Bomac
 

Users who are viewing this thread

Back
Top Bottom