Format Date "dd/mm/yyyy"

C

Carl_and_Earl

I have a bound text box and I want to display a date, but formated like this
"dd/mm/yyyy".
I tryed to input a mask like 99/99/0000;0;_, but when I insert in the text
box let's say 31/12/2008, on lost focus changes to 12/31/2008.

I also tryed to set VBA on lost focus.

Private Sub Data_LostFocus()
Dim MyResult, MyDate
MyDate = #12/31/2008#
MyResult = Format(MyDate, "dd/mm/yyyy")

Doesn't change a thing.
How can I change the format to be able to insert "dd/mm/yyyy"
Thanks.
 
P

Pendragon

On the properties for your bound text box, on the FORMAT tab and in the
Format property, type dd/mm/yyyy. This will get your result regardless of
the Input Mask.

For the Input Mask, for dates especially, I like to use 99/99/9999;;_ . That
way you allow the user to enter 08 or 2008 and still have a return display of
2008.

Also, and the Access gods should confirm this, but undefined variables I
think default to Variant. You should have your variables set to Date.

Dim MyResult as Date, MyDate as Date

But your code is unnecessary if the above Property changes are made to the
text box.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top