Fordraiders
asked on
format date field on certain entries
access 2010 text box date picker field with Short date as format
I sometimes have folks entering or copying and pasting
03312017 with no dashes.
or
332017
or
0312017
Access will not format automatically the short date: 03/31/2017
is there a way to capture this ?
Thanks
fordraiders
I sometimes have folks entering or copying and pasting
03312017 with no dashes.
or
332017
or
0312017
Access will not format automatically the short date: 03/31/2017
is there a way to capture this ?
Thanks
fordraiders
ASKER
Thanks rey,
for 222017
gave me
00/22/2017
fordraiders
for 222017
gave me
00/22/2017
fordraiders
There is really no safe way around this, as five digits can be read in so many ways that you can only guess the intention and probably make the wrong guess.
So set the Format property of the textbox to a date format, and an error will pop up if in invalid string is entered. And do educate the users to not use sloppy entry methods for entering important data.
/gustav
So set the Format property of the textbox to a date format, and an error will pop up if in invalid string is entered. And do educate the users to not use sloppy entry methods for entering important data.
/gustav
One cannot force access to think on his behalf.
To satisfy your specific example assuming:
t=ddmmyyyy 22032017
t=ddmyyyy 2232017
t=dmyyyy 232017
To satisfy your specific example assuming:
t=ddmmyyyy 22032017
t=ddmyyyy 2232017
t=dmyyyy 232017
d=format (iif(len(t)=8,format(t,"00/00/0000"),iif(len(t)=7,format(t,"00/0/0000"),format(t,"0/0/0000"))),"dd/mm/yyyy")
You can also train your people to take advantage of Access (and Excel's) ability to expand on what you type. For example, typing 3/31 will expand to 3/31/2017
typing 2/1 will expand to 2/1/17 which is either February 1st or January 2nd depending on what side of the pond you are on.
typing 2/1 will expand to 2/1/17 which is either February 1st or January 2nd depending on what side of the pond you are on.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thnx to all
private sub text0_afterupdate()
if instr(me.text0,"/")=0 then
me.text0=format(me.text0, "00/00/0000")
end if
end sub