UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Globalization Using Access In Different Countries, Access 2016    
 
   
Amateur
post Aug 31 2017, 11:14 AM
Post#1



Posts: 21
Joined: 8-December 04
From: UK, London


System.Globalization.CultureInfo


Hi

I tried to search for this topic here and else where on the web but not found anything that works because of my lack of understanding. iconfused.gif
If someone can spoon feed me a little that would help :-)

I wrote a small Access db that is going to be used in our French branch.
Basically, I need to split a string using commas as delimiters.
ct_Product = UBound(Split(str_Prod_Text, ","))
Works perfectly on my UK laptop!

But anyone with a French laptop with a French version of access throws up the comma as a semi-colon, so the count will always be 0!

I need to test the environment of the user.
I can use IF or Select so if the value returned is en-GB, I'll use the comma and if it is fr-FR then use semi-colon

There are lost of articles about System.Globalization.CultureInfo but everything I have tried failed.
How can I make this work System.Globalization.CultureInfo.CurrentCulture?

Anyone can please show me the basics? notworthy.gif

Thank you very much in advance!

Amateur
Go to the top of the page
 
JonSmith
post Aug 31 2017, 11:21 AM
Post#2



Posts: 3,158
Joined: 19-October 10



You are barking up the wrong tree. Checking that setting wont always work.
English doesnt always equal comma, French doesnt always equal column. You also might sometimes get German or something.
I moved to Amsterdam and got a job in Den Haag and some Dutch users have changed just the list separator. I keep my English settings, others have their own.

Now you shouldnt actually care what their global settings are, just the system list separator. You can read this easily in the system settings and then have it work regardless of the language.
Go to the top of the page
 
Amateur
post Aug 31 2017, 11:26 AM
Post#3



Posts: 21
Joined: 8-December 04
From: UK, London


Oh! That might work. How do I do that - Never heard of the ability to be able to do that!
Could you please show me the way?

Hopeful cheers.gif

Thank You
Go to the top of the page
 
JonSmith
post Aug 31 2017, 11:44 AM
Post#4



Posts: 3,158
Joined: 19-October 10



I'm on a train but will check the registry and get you the path you need.
Go to the top of the page
 
DanielPineault
post Aug 31 2017, 11:54 AM
Post#5


UtterAccess VIP
Posts: 5,437
Joined: 30-June 11



You should be able to use a function like:

CODE
Declare Function GetLocaleInfo Lib "kernel32" Alias _
                               "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, _
                                                 ByVal lpLCData As String, ByVal cchData As Long) As Long
Declare Function GetUserDefaultLCID% Lib "kernel32" ()
Public Const LOCALE_SLIST = &HC

Public Function GetListSeparator() As String
    On Error GoTo Error_Handler
    Dim ListSeparator         As String
    Dim iRetVal1              As Long
    Dim iRetVal2              As Long
    Dim lpLCDataVar           As String
    Dim Position              As Integer
    Dim Locale                As Long

    Locale = GetUserDefaultLCID()
    iRetVal1 = GetLocaleInfo(Locale, LOCALE_SLIST, lpLCDataVar, 0)
    ListSeparator = String$(iRetVal1, 0)
    iRetVal2 = GetLocaleInfo(Locale, LOCALE_SLIST, ListSeparator, iRetVal1)

    Position = InStr(ListSeparator, Chr$(0))
    If Position > 0 Then
        ListSeparator = Left$(ListSeparator, Position - 1)
        GetListSeparator = ListSeparator
    End If

Error_Handler_Exit:
    On Error Resume Next
    Exit Function

Error_Handler:
    MsgBox "The following error has occured" & vbCrLf & vbCrLf & _
           "Error Number: " & Err.Number & vbCrLf & _
           "Error Source: GetListSeparator" & vbCrLf & _
           "Error Description: " & Err.Description & _
           Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
           , vbOKOnly + vbCritical, "An Error has Occured!"
    Resume Error_Handler_Exit
End Function


to determine the user's separator at the db startup and store it to a TempVar and use it wherever you need it. Internalization is a real headache to get right! Don't forget, if you're doing any math, you need to localize the decimal separator, and so on.


You can also read these values directly from the registry. Check the HKEY_CURRENT_USER\Control Panel\International key they're all there. Look at sList, sDecimal, sDate, sCurrency to name but a few. As such, you could do something as simple as:

CODE
Debug.Print CreateObject("WScript.Shell").RegRead("HKEY_CURRENT_USER\Control Panel\International\sList")


You may also find https://msdn.microsoft.com/en-us/library/wi...9(v=vs.85).aspx useful to get a list of the constants.

--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...
Go to the top of the page
 
DanielPineault
post Aug 31 2017, 03:31 PM
Post#6


UtterAccess VIP
Posts: 5,437
Joined: 30-June 11



I was trying to refine the above and came across: http://www.theaccessweb.com/api/api0017.htm I should have know to look there first! crazy.gif

--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...
Go to the top of the page
 
Amateur
post Sep 1 2017, 03:36 AM
Post#7



Posts: 21
Joined: 8-December 04
From: UK, London


Daniel

You are a star! thanks.gif It works perfectly.
It picked up a comma as a separator on my machine and now I do a RDP into a french machine and it picked up the separator as a colon!
yayhandclap.gif
Fantastic! I am ever so grateful!!
And Thank You UtterAccess this is the best place for Access questions! pompom.gif

Have a great day everyone!!
Go to the top of the page
 
DanielPineault
post Sep 1 2017, 06:05 AM
Post#8


UtterAccess VIP
Posts: 5,437
Joined: 30-June 11



thumbup.gif

--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    11th December 2017 - 12:56 AM