Re: us date format
- From: Bob Wickham <wickham_bob@xxxxxxxxxxxx>
- Date: Sun, 22 Jan 2006 09:33:32 +1100
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 .
- Follow-Ups:
- Re: us date format
- From: RoyVidar
- Re: us date format
- References:
- us date format
- From: Bob Wickham
- Re: us date format
- From: Marshall Barton
- Re: us date format
- From: Bob Wickham
- Re: us date format
- From: RoyVidar
- us date format
- Prev by Date: Re: insert error
- Next by Date: Re: Compacting tempory file using code
- Previous by thread: Re: us date format
- Next by thread: Re: us date format
- Index(es):
Relevant Pages
|
Loading