Is there an easy way to make all negative values positive in a particular
table?
I've been experimenting with this:
Dim rst As DAO.Recordset
Set rst = db.OpenRecordse t("tblNegValues ")
Do
If rst!Amount < 0 Then rst!Amount = rst!Amount - (rst!Amount * 2)
Loop
Is there a better way? 12 28959
"deko" <dj****@hotmail .com> wrote in message
news:ON******** *********@newss vr29.news.prodi gy.com... Is there an easy way to make all negative values positive in a particular table?
I've been experimenting with this:
Dim rst As DAO.Recordset Set rst = db.OpenRecordse t("tblNegValues ")
Do If rst!Amount < 0 Then rst!Amount = rst!Amount - (rst!Amount * 2) Loop
Is there a better way?
The Abs function?
I'll bet Abs is more efficient than multiplication and subtraction, but I
still need a way to apply this to an entire table. Should I use For Each?
Must I use a Recordset operation here?
Thanks!
"rkc" <rk*@yabba.dabb a.do.rochester. rr.nope> wrote in message
news:fb******** *********@twist er.nyroc.rr.com ... "deko" <dj****@hotmail .com> wrote in message news:ON******** *********@newss vr29.news.prodi gy.com... Is there an easy way to make all negative values positive in a
particular table?
I've been experimenting with this:
Dim rst As DAO.Recordset Set rst = db.OpenRecordse t("tblNegValues ")
Do If rst!Amount < 0 Then rst!Amount = rst!Amount - (rst!Amount * 2) Loop
Is there a better way?
The Abs function?
Use an update query that only contains the Amount field. Put this expression
where it says Update To:
IIF([Amount] < 0,[Amount]*-1,[Amount])
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications re******@pcdata sheet.com www.pcdatasheet.com
"rkc" <rk*@yabba.dabb a.do.rochester. rr.nope> wrote in message
news:fb******** *********@twist er.nyroc.rr.com ... "deko" <dj****@hotmail .com> wrote in message news:ON******** *********@newss vr29.news.prodi gy.com... Is there an easy way to make all negative values positive in a particular table?
I've been experimenting with this:
Dim rst As DAO.Recordset Set rst = db.OpenRecordse t("tblNegValues ")
Do If rst!Amount < 0 Then rst!Amount = rst!Amount - (rst!Amount * 2) Loop
Is there a better way?
The Abs function?
Deko,
Why won't a simple update query do the trick for you?
UPDATE tblNegValues SET tblNegValues.Am ount = -[Amount]
WHERE tblNegValues.Am ount < 0
--
Hope this helps
Arno R
"deko" <dj****@hotmail .com> schreef in bericht
news:ON******** *********@newss vr29.news.prodi gy.com... Is there an easy way to make all negative values positive in a particular table?
I've been experimenting with this:
Dim rst As DAO.Recordset Set rst = db.OpenRecordse t("tblNegValues ")
Do If rst!Amount < 0 Then rst!Amount = rst!Amount - (rst!Amount * 2) Loop
Is there a better way?
dj****@hotmail. com (deko) wrote in
<Tz************ ****@newssvr29. news.prodigy.co m>: I'll bet Abs is more efficient than multiplication and subtraction, but I still need a way to apply this to an entire table. Should I use For Each? Must I use a Recordset operation here?
If you're changing all the values in a column in a table, or a
subset of values that match certain criteria, SQL is definitely the
way to go. Arno has given you one such solution.
A SQL UPDATE is almost always going to be faster than walking
through a recordset and changing one row at a time, though there
are some kinds of changes that can't really be done with SQL, so
you sometimes do need to walk a recordset. But it's not nearly as
often as many people think (especially people who come from an
xBase environment).
--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Thanks for the reply.
You're right - an update query is the way to go. "Amount = -Amount" is
simple enough, and works great. I was focusing too much on the arithmetic
operations I thought were necessary to convert the negative to a positive
and didn't think I could do it with SQL.
I think Abs is a good way to go, too (rck's suggestion).
UPDATE tblNegValues SET Amount = Abs(Amount) WHERE Amount < 0
"Arno R" <ar************ ****@tiscali.nl > wrote in message
news:3f******** **************@ dreader2.news.t iscali.nl... Deko, Why won't a simple update query do the trick for you?
UPDATE tblNegValues SET tblNegValues.Am ount = -[Amount] WHERE tblNegValues.Am ount < 0
-- Hope this helps Arno R "deko" <dj****@hotmail .com> schreef in bericht news:ON******** *********@newss vr29.news.prodi gy.com... Is there an easy way to make all negative values positive in a
particular table?
I've been experimenting with this:
Dim rst As DAO.Recordset Set rst = db.OpenRecordse t("tblNegValues ")
Do If rst!Amount < 0 Then rst!Amount = rst!Amount - (rst!Amount * 2) Loop
Is there a better way?
"deko" <dj****@hotmail .com> wrote in news:ONjHb.2907 $NJ7.1857
@newssvr29.news .prodigy.com: Is there an easy way to make all negative values positive in a particular table?
I've been experimenting with this:
Dim rst As DAO.Recordset Set rst = db.OpenRecordse t("tblNegValues ")
Do If rst!Amount < 0 Then rst!Amount = rst!Amount - (rst!Amount * 2) Loop
Is there a better way?
I suppose (whimsically), that you are storing a calculated field if you do
this, and that you should leave your data as it is, and simply use and/or
display the absolute value of these values.
--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
hi,
update MyTable
Set Amount=(Amount*-1)
where Amount <0
"deko" <dj****@hotmail .com> schrieb im Newsbeitrag
news:ON******** *********@newss vr29.news.prodi gy.com... Is there an easy way to make all negative values positive in a particular table?
I've been experimenting with this:
Dim rst As DAO.Recordset Set rst = db.OpenRecordse t("tblNegValues ")
Do If rst!Amount < 0 Then rst!Amount = rst!Amount - (rst!Amount * 2) Loop
Is there a better way?
Actually, it's part of an import process that downloads bank statements and
populates a table with all the various transactions. The database then
crunches the numbers, which need to be all positive values. But the
different banks are not consistent in how they represent the amounts - some
are negative (2,483.39), some are positive $2,483.39.
This seems to do the trick:
UPDATE tblTransactions SET Amount = Abs(Amount) WHERE Amount < 0
Thanks to all who replied - I appreciate the help!
"Lyle Fairfield" <Mi************ @Invalid.Com> wrote in message
news:Xn******** ***********@130 .133.1.4... "deko" <dj****@hotmail .com> wrote in news:ONjHb.2907 $NJ7.1857 @newssvr29.news .prodigy.com:
Is there an easy way to make all negative values positive in a
particular table?
I've been experimenting with this:
Dim rst As DAO.Recordset Set rst = db.OpenRecordse t("tblNegValues ")
Do If rst!Amount < 0 Then rst!Amount = rst!Amount - (rst!Amount * 2) Loop
Is there a better way?
I suppose (whimsically), that you are storing a calculated field if you do this, and that you should leave your data as it is, and simply use and/or display the absolute value of these values.
-- Lyle (for e-mail refer to http://ffdba.com/contacts.htm) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dirk Hagemann |
last post by:
Hi,
Is there a datatype in python which allows no negative values? I
subtract several times something from a value and I don't want to chek
everytime if this value is still bigger or equal 0.
Thanks for help!
Dirk Hagemann
|
by: luke |
last post by:
Could anyone, please, explain to me why I have negative values in
RowModCtr column in sysobjects table? I have tested that after I update
statistics the RowModCtr column is reset to 0. But why do I have
negative values in the first place? Thx.
|
by: bafidi |
last post by:
i write a number to textbox1.text
i want to learn if it is negative or positive
|
by: illegal.prime |
last post by:
So I see from the documentation here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemCollectionsArrayListClassBinarySearchTopic.asp
That the code uses the less than operator:
int myIndex=myList.BinarySearch( myObject );
if ( myIndex < 0 )
when using the BinarySearch method and in my own experience I see that
sometimes it returns other negative values (other than -1).
|
by: Badis |
last post by:
Hi guys,
I have a negative values in my Amount column in GridView could U tell me how
to display them with no (-) sign in front, knowing that my gridview is
bounded to a DataView.
Thanks
| |
by: Badis |
last post by:
Hi guys,
I have a negative values in my Amount column in GridView could U tell me how
to display them with no (-) sign in front, knowing that my gridview is
bounded to a DataView.
Thanks
|
by: vimal |
last post by:
hi all,
i am new to python guys.
hope u will help me with this....
i have a list of numbers
say a =
how should i check for negative values in the list
|
by: bengevik |
last post by:
I need to multiplicate all the values in a coloumn with a constant and returning them in a (eventually new) column.
My second problem is that there are negative values in some rows. I need to convert these values in this way:
6,28 - (value)
into positive values.
Is there any functions for these operations and how will it look like?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |