views:

1601

answers:

2

There is a problem in VBA text box while filling input mask property:

I am trying to make the combination of date and time:

Hence i put it like below:

00/00/00;0;_00:00;0;_

But while running the application, i am only getting 00/00/00 (Date).

But i remember, i got the result as like 00/00/00 00.00 as expected when i first put the expression as like above;

but now i am not getting it :-(

+1  A: 

The InputMask property can contain up to three sections separated by semicolons (;)

Your mask should be like this:

"00/00/00 00:00;0;0"

or

"00/00/00 00:00;0;_" // to display it like __/__/__ __:__
Nick D
Thanks a ton !!!
thanks Jaison. Cheers :)
Nick D
Hi there?In the above ; i am getting 00/00/00 formati want it in _ _/ _ _/_ _ underscore format. Any hope ?
Jaison, I updated it.
Nick D
A: 

Why not just use the built in "General Date" format? I've found over the years that input masks are very restricting and basically a pain. Although it's been so long since I've used them that I don't recall the details of why I despise them.

This also has the benefit of respecting the users choices of regional date format. For example I always use yyyy-mm-dd format.

Also a client had a situation where the date format was decreed to be Medium Date on all fields. Which is dd-mmm-yy. It later turned out that in a table of 100K records there were twelve dates before 1900. They had simple had something extra keyed in in the year so Windows/Access interpreted those dates as being in the 3rd or 5th century or whatever. Now these dates weren't used in any kind of calculation so it wasn't a big deal. SQL Server upsizing to small date/time fields didn't appreciate those though.

Tony Toews
I would use the SQL upsizing argument as the justification for using date masks. I ran into exactly the same problem when upsizing an app a few years ago that had data in it that predated my adding date masks that required 4-digit years -- it had some records that were dated to the late Roman Empire. A date mask would have prohibited that data ever being entered. I don't know any easier way to do that. Why write code for the BeforeUpdate that has to parse the input when the input mask will do it for you (and display the model format, to boot)?
David-W-Fenton
I'd prefer if everyone used a four digit year on their date formats and be done with the entire problem.
Tony Toews
"A date mask would have prohibited that data ever being entered" -- if you don't consider covering this with a data integrity constraint (Validation Rule or CHECK constraint for the date range, FOREIGN KEY to your Calendar table, etc) then you may be being a little naive.
onedaywhen