I have made a listbox, which I maintain using an SQL string. Problem is that in The Netherlands most international settings on computers have dots as thousand separator and comma's as decimal separator (i.e. $1.000,00)
I would want to convert that number to the american standard, because american standards is all that SQL statements accept. Converting a date is easy, using the VBA format function (i.e. datAnyDate = format([date],"mm/dd/yyyy"). However, I can't get it right with numbers. This is what I tried:
tblField in this example has the property number with field size double.
The result of strValue is a value with a dot in it as decimal separator. I expected the replace function to do this, so this works right. The result of dblValue in this code is still the value including a comma as separator (as it is set in the international settings of the computer). It doesn't surprise me that the Val function converts the number with a comma as decimal separator again. Obviously it is not possible to use strValue in the SQL statement. After all, it's a string, so using this in an SQL statement requires the use of quotes.
I really need this piece of code to work independently from the locale international settings of the computer. Who is smart enough to make the SQL statement work independently from the international settings of the computer?
I would want to convert that number to the american standard, because american standards is all that SQL statements accept. Converting a date is easy, using the VBA format function (i.e. datAnyDate = format([date],"mm/dd/yyyy"). However, I can't get it right with numbers. This is what I tried:
Code:
Dim strValue as string
Dim dblValue as double
strValue = Replace(Me.cboSelection1, ",", ".")
dblValue = Val(strValue)
me.listbox.recordset = ("SELECT * FROM tblYYY WHERE tblField = " & dblValue)
The result of strValue is a value with a dot in it as decimal separator. I expected the replace function to do this, so this works right. The result of dblValue in this code is still the value including a comma as separator (as it is set in the international settings of the computer). It doesn't surprise me that the Val function converts the number with a comma as decimal separator again. Obviously it is not possible to use strValue in the SQL statement. After all, it's a string, so using this in an SQL statement requires the use of quotes.
I really need this piece of code to work independently from the locale international settings of the computer. Who is smart enough to make the SQL statement work independently from the international settings of the computer?