How to convert Decimal number with comma(,) as decimal separator to dot(.)

  • Thread starter Thread starter Domac
  • Start date Start date
D

Domac

Hi,

I am having problem with decimals in VBA code.
I am "injecting" value from textbox into UPDATE sql statment, but I get an
error because i am having comma as a separator.
How to convert 0,254 into 0.255 without changing regional settings!
 
Should I disassemble it as a string and then "rebuild" it with dot as a
separator?

I don't need this format anywhere but to insert it in Sql statment string!

Example :

I need this :

UPDATE SomeTable SET SomeTable.DecimalField = 0.255 ......

But I am getting this:

UPDATE SomeTable SET SomeTable.DecimalField = 0,255 ......

and error occurs because comma is argument separator operator.
 
The best way is to create a Parameter Query
Query: updDecValue

PARAMETERS pDecValue IEEEDouble;
UPDATE TheTable Set TheField=pDecValue;

Usage:
Dim Db AS DAO.Database
Dim QDef AS DAO.QueryDef

Set Db = Access.CurrentDb
Set Qdef = Db.QueryDefs("updDecValue")
Qdef.Parameters("pDecValue").Value = Forms!MyForm!TheTextBox.Value ' Will
convert to Decimal value
Qdef.Execute DAO.DbSeeChanges
....
Set Db = Nothing

Simplier is offcourse
Access.DoCmd.RunSQL "UPDATE TheTable Set TheField=Forms!MyForm!TheTextBox;"

But ...

HTH

Pieter
 
Back
Top