Re: us date format



RoyVidar wrote:
Bob Wickham wrote in message <43d2a9f3@xxxxxxxxxxxxxxxxx> :

Marshall Barton wrote:

Bob Wickham wrote:

I have a form where the user enters a date in each record.
In many records the date stays the same so I have written the following code that inserts the previous records value into the current record.


Private Sub PaymentDate_AfterUpdate()

   Me![PaymentDate].DefaultValue = "#" & Me![PaymentDate] & "#"

End Sub

Works OK, except when the value is inserted it displays as US date mm/dd/yy.
I'm typing dd/mm/yy in the first record
I live in Australia and want it to appear as dd/mm/yy in the next record.


I believe I need to convert the date to a number with CLng but I've tried all sorts of ways and cant get it to happen.




I think all you need to do is set the text box's Format
property to:
    dd/mm/yy

No, sorry Marshall, that didn't make any difference.
The format property was Short Date and I have now changed it dd/mm/yy

In both cases, entering 12/06/05 (the 12th day of June, 2005)in the first record displays as 06/12/05 in the second.

Bob


You need even one step further (watch for linebreaks)

Me![PaymentDate].DefaultValue = "#" & format$(Me![PaymentDate], "yyyy-mm-dd") & "#"

or check out this page by Allen Browne
http://allenbrowne.com/ser-36.html
for more information

Thanks Roy and Marshall,

That fixed it.
Info for anybody else confused about all this.
This code: (without line breaks)
Me![PaymentDate].DefaultValue = "#" & Format$(Me![PaymentDate], "yyyy-mm-dd") & "#"
will display dates according to the text boxes Format property, as Marshall suggested.
In my case:
dd/mm/yy will display 12/06/05 (12th day of June, 05)
Short Date will display according to your regional settings eg dd/mm/yyyy (12/06/2005) (12th day of June, 2005)


Yes, it works, but, I have read several posts (notably Steve Schapel) suggesting that dates be converted using CLng so as to eliminate any confusion about all the different date formats.
Can anyone explain how I would use CLng with my current problem.


Bob
.



Relevant Pages

  • Re: us date format
    ... Bob Wickham wrote in message: ... will display dates according to the text boxes Format property, ... Yes, it works, but, I have read several posts suggesting that dates be converted using CLng so as to eliminate any confusion about all the different date formats. ...
    (microsoft.public.access.formscoding)
  • Re: us date format
    ... >>> confusion about all the different date formats. ... >>> Can anyone explain how I would use CLng with my current problem. ... >> need to pass it in an unambiguous format. ... For string conversions, as Roy ...
    (microsoft.public.access.formscoding)
  • Re: us date format
    ... will display dates according to the text boxes Format property, ... Yes, it works, but, I have read several posts suggesting that dates be converted using CLng so as to eliminate any confusion about all the different date formats. ... I'm not sure formatting to long will work in this scenario, and I'm not sure how it would work against other databases, for instance SQL server or Oracle ... ...
    (microsoft.public.access.formscoding)
  • Re: us date format
    ... will display dates according to the text boxes Format property, ... Yes, it works, but, I have read several posts suggesting that dates be converted using CLng so as to eliminate any confusion about all the different date formats. ...
    (microsoft.public.access.formscoding)
  • Re: us date format
    ... will display dates according to the text boxes Format property, ... Yes, it works, but, I have read several posts suggesting that dates be converted using CLng so as to eliminate any confusion about all the different date formats. ...
    (microsoft.public.access.formscoding)

Loading