?
Solved

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

Posted on 2003-03-06
5
Medium Priority
?
368 Views
Last Modified: 2008-01-16
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.
Thanks
0
Comment
Question by:rlouw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 11

Expert Comment

by:Steiner
ID: 8079018
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).

Greets
Steiner
0
 

Author Comment

by:rlouw
ID: 8079056
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.
Rykie
0
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 200 total points
ID: 8079337
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 Const HWND_BROADCAST = &HFFFF&
Public Const WM_WININICHANGE = &H1A

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()
PostMessage HWND_BROADCAST, WM_WININICHANGE, 0, 0
End Sub


0
 

Author Comment

by:rlouw
ID: 8134262
Thank you.  I have tried it and I am very happy with the results.

Rykie Louw
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8135876
Glad to help. Thanks for "A" grade!
Cheers
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month11 days, 13 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question