I need to change regional settings within Access (versions 2010, 2013, 2016) and have tried using the following code
Public Const HWND_BROADCAST = &HFFFF&
Public Const WM_SETTINGCHANGE = &H1A
Public Const LOCALE_SCURRENCY = &H14
Public Declare Function SetLocaleInfo Lib "kernel32" Alias "SetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String) As Boolean
Public Declare Function GetUserDefaultLCID Lib "kernel32" () As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Sub SetCurrencyFormat(format As String)
Dim lngIdentifier As Long
lngIdentifier = GetUserDefaultLCID()
If SetLocaleInfo(lngIdentifier, LOCALE_SCURRENCY, format) = False Then
MsgBox "Error occured while trying to change the setting."
End If
End Sub
Call SetCurrencyFormat("$")
'send a system notification
Call PostMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0&, ByVal 0&)
The code does change the settings on the machine but to get Access to use the new settings, Access has to be closed and re-opened.
Is there any way to get Access to recognise the new Regional Settings without closing and reopening?
Any help would be most appreciated.
Thank you.