Results 1 to 4 of 4
  1. #1
    seshan is offline Novice
    Windows Vista Access 2003
    Join Date
    Jan 2010
    Posts
    3

    Decimal seperator between different languages

    Hi,
    I am forming a Dynamic SQL using a decimal number in a different Regional language, which has comma as a decimal separator. How do I convert the decimal number to the format that can be used inside a query.

    Thanks in advance

  2. #2
    ChrisO is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2005
    Location
    Brisbane, Australia
    Posts
    27
    Dim MyNumber As Double

    MyNumber = 123.456

    MsgBox Replace(CStr(MyNumber), ",", ".")

  3. #3
    seshan is offline Novice
    Windows Vista Access 2003
    Join Date
    Jan 2010
    Posts
    3
    How do we identify the decimal separator in VBA when we use a lot of languages?

    What is the purpose of Str function? Can it be used for this purpose. When we wrap a decimal number whose decimal separator is comma with an Str function, the decimal seperator appears to be a period. Is it doing a conversion internally?

  4. #4
    ChrisO is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2005
    Location
    Brisbane, Australia
    Posts
    27
    You do not need to identify the decimal separator, simply replace it with a period if it is there.

    The Replace function works on a string argument so if we feed it a number Access will convert it to a string and then process it.

    It’s when Access converts it to a string that it looks at the regional settings and inserts what ever is set as the regional decimal separator.

    So let’s say we have a number say 1.2 (always a period as a number) and we convert it to a string with say English(US) regional settings we get 1.2 (with a period)
    however if we are using German (Germany) settings we get 1,2 (with a comma)

    If we build an SQL string such as: -
    "Select * From Blah Where ID = " & MyNumber

    With English(US) regional settings we get: -
    Select * From Blah Where ID = 1.2
    And it works.

    But with German (Germany) settings we get: -
    Select * From Blah Where ID = 1,2
    And it fails.

    If we use: -
    "Select * From Blah Where ID = " & Replace(MyNumber, ",", ".")
    We get: -
    Select * From Blah Where ID = 1.2
    And it works with both regional settings.

    Try testing it and change your regional settings to German (Germany).

Please reply to this thread with any new information or opinions.

Similar Threads

  1. 12 Zeros past decimal
    By WhatnThe in forum Access
    Replies: 24
    Last Post: 01-03-2010, 09:53 PM
  2. Replies: 1
    Last Post: 09-29-2009, 04:34 AM
  3. Please help w/ simple languages db
    By TalentNation.net in forum Database Design
    Replies: 0
    Last Post: 01-23-2009, 09:11 AM
  4. Non programer needs help in decimal numbers
    By Peter O in forum Access
    Replies: 1
    Last Post: 10-07-2008, 12:29 PM
  5. Get the sum of decimal values - weird results
    By BengtCarlsson in forum Queries
    Replies: 2
    Last Post: 02-10-2006, 04:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums