PC Review


Reply
Thread Tools Rate Thread

Problem with Regional Settings decimal separator and SQL

 
 
juvi
Guest
Posts: n/a
 
      8th Apr 2008
Hello,

I have got a little problem. My form has a textbox where the user can enter
a decimal value and after LostFocus event a second textbox gets a value from
a SQL query.

The problem is that the user insert "10,36" and the SQL query only works
with "10.36". How could I change the separator "," to "." only for this Event?

The regional settings from the target machine is "," so it seems that only
SQL need the "."

Thx for any help
 
Reply With Quote
 
 
 
 
Alex Dybenko
Guest
Posts: n/a
 
      8th Apr 2008
Hi,
you can just replace comma with dot in this event:

strNewVal=replace(me.textbox1,",",".")

and then use strNewVal in your query

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com


"juvi" <(E-Mail Removed)> wrote in message
news:6FBACE75-AA03-4739-814F-(E-Mail Removed)...
> Hello,
>
> I have got a little problem. My form has a textbox where the user can
> enter
> a decimal value and after LostFocus event a second textbox gets a value
> from
> a SQL query.
>
> The problem is that the user insert "10,36" and the SQL query only works
> with "10.36". How could I change the separator "," to "." only for this
> Event?
>
> The regional settings from the target machine is "," so it seems that only
> SQL need the "."
>
> Thx for any help


 
Reply With Quote
 
 
 
 
juvi
Guest
Posts: n/a
 
      9th Apr 2008
hello, thank you for your reply. This workaround works to avoid the SQL-query
error but I receive wrong result for query.

The data is stored as "10,36" in the table and if I want to change it to
"10.36" access converts the field automatically to "1036" so the value in my
query is also converted to a value without separator!? what can I do to get
this work?

thx

"Alex Dybenko" wrote:

> Hi,
> you can just replace comma with dot in this event:
>
> strNewVal=replace(me.textbox1,",",".")
>
> and then use strNewVal in your query
>
> --
> Best regards,
> ___________
> Alex Dybenko (MVP)
> http://accessblog.net
> http://www.PointLtd.com
>
>
> "juvi" <(E-Mail Removed)> wrote in message
> news:6FBACE75-AA03-4739-814F-(E-Mail Removed)...
> > Hello,
> >
> > I have got a little problem. My form has a textbox where the user can
> > enter
> > a decimal value and after LostFocus event a second textbox gets a value
> > from
> > a SQL query.
> >
> > The problem is that the user insert "10,36" and the SQL query only works
> > with "10.36". How could I change the separator "," to "." only for this
> > Event?
> >
> > The regional settings from the target machine is "," so it seems that only
> > SQL need the "."
> >
> > Thx for any help

>
>

 
Reply With Quote
 
Alex Dybenko
Guest
Posts: n/a
 
      10th Apr 2008
When you enter data in a table - access recognize decimal as it set in
regional settings. but when you type it in SQL or VBA - then it should be
dot. so depending on where you enter this value you need to convert it to .
or ,

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com

"juvi" <(E-Mail Removed)> wrote in message
news:7BF45457-42A8-4405-81D3-(E-Mail Removed)...
> hello, thank you for your reply. This workaround works to avoid the
> SQL-query
> error but I receive wrong result for query.
>
> The data is stored as "10,36" in the table and if I want to change it to
> "10.36" access converts the field automatically to "1036" so the value in
> my
> query is also converted to a value without separator!? what can I do to
> get
> this work?
>
> thx
>
> "Alex Dybenko" wrote:
>
>> Hi,
>> you can just replace comma with dot in this event:
>>
>> strNewVal=replace(me.textbox1,",",".")
>>
>> and then use strNewVal in your query
>>
>> --
>> Best regards,
>> ___________
>> Alex Dybenko (MVP)
>> http://accessblog.net
>> http://www.PointLtd.com
>>
>>
>> "juvi" <(E-Mail Removed)> wrote in message
>> news:6FBACE75-AA03-4739-814F-(E-Mail Removed)...
>> > Hello,
>> >
>> > I have got a little problem. My form has a textbox where the user can
>> > enter
>> > a decimal value and after LostFocus event a second textbox gets a value
>> > from
>> > a SQL query.
>> >
>> > The problem is that the user insert "10,36" and the SQL query only
>> > works
>> > with "10.36". How could I change the separator "," to "." only for this
>> > Event?
>> >
>> > The regional settings from the target machine is "," so it seems that
>> > only
>> > SQL need the "."
>> >
>> > Thx for any help

>>
>>


 
Reply With Quote
 
juvi
Guest
Posts: n/a
 
      10th Apr 2008
thank you for your reply. So how can I get this work?

my query is something like:

SELECT * FROM tbl_Prices WHERE weight=2.5

here I get the records for weight= 25!?!

SELECT * FROM tbl_Prices WHERE weight=2,5

here I get an exception for comma (3075)

So how can I now make my query to get results for 2,5???

thx

"Alex Dybenko" wrote:

> When you enter data in a table - access recognize decimal as it set in
> regional settings. but when you type it in SQL or VBA - then it should be
> dot. so depending on where you enter this value you need to convert it to .
> or ,
>
> --
> Best regards,
> ___________
> Alex Dybenko (MVP)
> http://accessblog.net
> http://www.PointLtd.com
>
> "juvi" <(E-Mail Removed)> wrote in message
> news:7BF45457-42A8-4405-81D3-(E-Mail Removed)...
> > hello, thank you for your reply. This workaround works to avoid the
> > SQL-query
> > error but I receive wrong result for query.
> >
> > The data is stored as "10,36" in the table and if I want to change it to
> > "10.36" access converts the field automatically to "1036" so the value in
> > my
> > query is also converted to a value without separator!? what can I do to
> > get
> > this work?
> >
> > thx
> >
> > "Alex Dybenko" wrote:
> >
> >> Hi,
> >> you can just replace comma with dot in this event:
> >>
> >> strNewVal=replace(me.textbox1,",",".")
> >>
> >> and then use strNewVal in your query
> >>
> >> --
> >> Best regards,
> >> ___________
> >> Alex Dybenko (MVP)
> >> http://accessblog.net
> >> http://www.PointLtd.com
> >>
> >>
> >> "juvi" <(E-Mail Removed)> wrote in message
> >> news:6FBACE75-AA03-4739-814F-(E-Mail Removed)...
> >> > Hello,
> >> >
> >> > I have got a little problem. My form has a textbox where the user can
> >> > enter
> >> > a decimal value and after LostFocus event a second textbox gets a value
> >> > from
> >> > a SQL query.
> >> >
> >> > The problem is that the user insert "10,36" and the SQL query only
> >> > works
> >> > with "10.36". How could I change the separator "," to "." only for this
> >> > Event?
> >> >
> >> > The regional settings from the target machine is "," so it seems that
> >> > only
> >> > SQL need the "."
> >> >
> >> > Thx for any help
> >>
> >>

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
decimal separator, regional settings pax Microsoft Dot NET Framework 9 30th May 2007 11:37 PM
decimal separator, regional settings pax Microsoft ADO .NET 9 30th May 2007 11:37 PM
decimal separator, regional settings pax Microsoft Dot NET Framework Forms 9 30th May 2007 11:37 PM
decimal separator, regional settings pax Microsoft Dot NET 2 28th May 2007 01:46 AM
decimal separator, regional settings pax Microsoft C# .NET 2 28th May 2007 01:46 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:22 AM.