Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 384
  • Last Modified:

How to change currency setting (Windows API) using VBA in Access

I have found an article how to change short date of regional settings using VBA in Access.  I would like to do the same with currency.  Can anybody please help me.
  • 2
  • 2
1 Solution
How do you change your short date in Access (neither do I know that article nor do I have Access)?
I just change the registry key for the short date. The same should work with the currency to (key sCurrency instead of sShortDate).

rlouwAuthor Commented:
I use dates in MS Access (97 and 2000)to base calculations on. My uses are lock unto a network and every time they lock on, the server change their date settings.  I have found M Knowledge based article 168793 on how to change their short date settings from VB in Access each time they lock into my Access system.  I want to do the same with currency as they are inexperienced PC users and I do not what to leave it up to them to do the changes manually.
Richie_SimonettiIT OperationsCommented:
i have a module to manage all regional settings:

Option Explicit
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 SetLocaleInfo Lib "kernel32" Alias _
"SetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, _
ByVal lpLCData As String) As Boolean

Declare Function GetUserDefaultLCID% Lib "kernel32" ()

'Enum para envio de valores
'de la configuracion regional.
Public Enum LOCAL_INFO
  ICountry = &H5
  ICurrencyDecDigits = &H19
  IDefaultCodePage = &HB
  IIDEDefCountry = &HA
  IIDEDefLang = &H9
  IDecDigits = &H11
  SyAM = &H28
  SyPM = &H29
  SyShortCtryName = &H7
  SyShortDayName1 = &H31
  SyShortDayName2 = &H32
  SyShortDayName3 = &H33
  SyShortDayName4 = &H34
  SyShortDayName5 = &H35
  SyShortDayName6 = &H36
  SyShortDayName7 = &H37
  SyShortLangName = &H3
  SymShortMonthName1 = &H44
  SyCountry = &H6
  SyShortCurrency = &H14
  SyDateSep = &H1D
  SyLongDayName1 = &H2A
  SyLongDayName2 = &H2B
  SyLongDayName3 = &H2C
  SyLongDayName4 = &H2D
  SyLongDayName5 = &H2E
  SyLongDayName6 = &H2F
  SyLongDayName7 = &H30
  SymCtryNameInEng = &H1002
  SyLangInEnglish = &H1001
  SyNumberDigitsGroup = &H10
  SyInternacLang = &H15
  SKeybDistrib = &H2
  SyListSep = &HC
  SyLongDate = &H20
  SyDecimalSep = &H16
  ICurrencyDigitsGroup = &H18
  SyMonthName1 = &H38
  SyMonthName2 = &H39
  SyMonthName3 = &H3A
  SyMonthName4 = &H3B
  SyMonthName5 = &H3C
  SyMonthName6 = &H3D
  SyMonthName7 = &H3E
  SyMonthName8 = &H3F
  SyMonthName9 = &H40
  SyMonthName10 = &H41
  SyMonthName11 = &H42
  SyMonthName12 = &H43
  SyCurrencyThousandSep = &H17
  SyNativeCtryName = &H8
  SyNativeDigits = &H13
  SyNativeLangName = &H4
  SyNegativeSign = &H51
  SyPositiveSign = &H50
  SyShortDate = &H1F
  SyThousand = &HF
  SyHourSeparator = &H1E
  SyHourFormat = &H1003
End Enum

Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Public Function Get_locale(RSValue As LOCAL_INFO) ' Retrieve the regional setting

      Dim Symbol As String
      Dim iRet1 As Long
      Dim iRet2 As Long
      Dim lpLCDataVar As String
      Dim Pos As Integer
      Dim Locale As Long
      Locale = GetUserDefaultLCID()

      iRet1 = GetLocaleInfo(Locale, RSValue, _
      lpLCDataVar, 0)
      Symbol = String$(iRet1, 0)
      iRet2 = GetLocaleInfo(Locale, RSValue, Symbol, iRet1)
      Pos = InStr(Symbol, Chr$(0))
      If Pos > 0 Then
           Symbol = Left$(Symbol, Pos - 1)
           Get_locale = Symbol
      End If

End Function

Public Function Set_locale(RSValue As LOCAL_INFO, Symbol As String) 'Change the regional setting
      Dim iRet As Long
      Dim Locale As Long

      Locale = GetUserDefaultLCID() 'Get user Locale ID
      iRet = SetLocaleInfo(Locale, RSValue, Symbol)
End Function
Public Sub Anounce_locale_change()
End Sub

rlouwAuthor Commented:
Thank you.  I have tried it and I am very happy with the results.

Rykie Louw
Richie_SimonettiIT OperationsCommented:
Glad to help. Thanks for "A" grade!

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now