C
Carl_and_Earl
I want to make a field to change the date from 1.1.2009 to 01.01.2009 on lost
focus.
Thanks!
focus.
Thanks!
What is the Format property of the form textbox? -> Short Date
On your Windows desktop select Start... Control Panel... Regional and Language
Settings. What's the Short Date format? ->3/31/2009
Thanks John, but it didn't work. I did what you told me, but to change the
field to 01.01.2009 I have to type first 01/01/2009 otherwise it wouldn't let
me to enter the date and I want to input just 1.1.2009 when I tipe to
simplify it.

Carl_and_Earl said:I want to make a field to change the date from 1.1.2009 to 01.01.2009 on lost
focus.
Thanks!
James said:Maybe:
Private Sub txtX_LostFocus()
If IsDate(Replace(txtX.Value, ".", "/")) = False Then
MsgBox ("Invalid Date")
Exit Sub
End If
If Not IsNull(txtX.Value) Then txtX.Value _
= Replace(Format(Replace(txtX.Value, ".", "/"), _
"mm/dd/yyyy"), "/", ".")
End Sub
Note: txtX's Format property should be blank.
James A. Fortune
(e-mail address removed)
This might be better:
Private Sub txtX_LostFocus()
If Not IsNull(txtX.Value) Then
If IsDate(Replace(txtX.Value, ".", "/")) = False Then
MsgBox ("Invalid Date")
Exit Sub
End If
txtX.Value = Replace(Format(Replace(txtX.Value, ".", "/"), _
"mm/dd/yyyy"), "/", ".")
End If
End Sub
John said:VERY clever, James... thank you! Filed for future reference (with
attribution). Didn't realize you could tweak the Value property in LostFocus
like that.