Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fomat local in control

Status
Not open for further replies.

MikeCDPQ

Technical User
Sep 11, 2003
173
0
0
CA
I have a form that uses if conditions in certain controls.

Something similar to:
If province = Quebec then "Bonjour" else "Hello"

Based on this same condition I need to translate a date to French.

In Excel, one would use:Selection.NumberFormat = "[$-C0C]d mmmm, yyyy;@"

What would the equivalent be in a form control or query ?

Thanks for any suggestions.

Mike
 
the format function will allow you to format your dates however you want...

--------------------
Procrastinate Now!
 
I know about the format function but I dont know how to display for exemple: Janvier in French instead of January in English.

Thanks anyway !

Any other solution anyone ?

 
I found my own solution. Might not be pretty but it works.

Created a table with month numeric value and month French description. Linking month value from date to month value in other query. I then recreate the date in French with dateparts concatenation.

According to my condition I either see: April 19, 2007 or 19 avril 2007.


 
How are ya MikeMcKesson . . .

Instead of [blue]wasting resources[/blue] on a table (at least for months), the following function should do. The function comes with a nice twist . . . you can specify month [blue]integers 1 thru 12[/blue] or any date greater than Jan-11-1900 to return the month in french! This should makes things eaiser for your vba, query and sql.

In a [blue]module[/blue] in the [blue]modules[/blue] window, copy/paste the following:
Code:
[blue]Public Function FrenchMonth(usrDate As Date) As String
   Dim idx As Integer
   
   If usrDate < #1/12/1900# Then
      idx = DateSerial(Year(usrDate), Month(usrDate), Day(usrDate))
   Else
      idx = Month(usrDate)
   End If
   
   FrenchMonth = Choose(idx, "Janvier", _
                             "Février", _
                             "Mars", _
                             "Avril", _
                             "Mai", _
                             "Juin", _
                             "Juillet", _
                             "Août", _
                             "Septembre", _
                             "Octobre", _
                             "Novembre", _
                             "Décembre")

End Function[/blue]
Examples:
Code:
[blue][b][i]variable[/i][/b] = FrenchMonth(8) [green]'returns Août[/green]
[b][i]variable[/i][/b] = FrenchMonth(#Dec-12-2000#) [green]'returns Décembre[/green]

Dim MyDate as Date
Mydate = #09-29-2004#
[b][i]variable[/i][/b] = FrenchMonth(MyDate) [green]'returns Septembre[/green][/blue]
[blue]Cheers! [thumbsup2] . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
Thanks TheAceMan1

That's not something I can use in this particular situation but I do see plenty of other applications where I can use the code.

You're the best !

Thanks a millon.

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top