473,326 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

update field

Update filed with percentage

In the table Products we have to update the field SalesPrice with 2
percents . We have to increase all the Sales Prices of our products
with 2 percent.Our idea is to multiply the price with 1.2 for all the
products. However, I get the message " Syntax error in update
statement.
Could someone help me ?
I tried to use the following function:
Public Function IncreaseSalesPricewith2Percent()
Dim db As DAO.Database
Set db = CurrentDb
db.Execute "UPDATE Products WHERE SalesPrice = SalesPrice * 1.2"
Set db = Nothing
End Function
Nov 12 '05 #1
3 2323
Isn't multiplying by 1.2 going to increase the price by 20%? Your bank
account will love it. But it might be a little bit of a shock to your
customers :-)
I suggest trying

DoCmd.RunSQL "UPDATE Products SET SalesPrice = SalesPrice * 1.02"

Pavel

Johm wrote:

Update filed with percentage

In the table Products we have to update the field SalesPrice with 2
percents . We have to increase all the Sales Prices of our products
with 2 percent.Our idea is to multiply the price with 1.2 for all the
products. However, I get the message " Syntax error in update
statement.
Could someone help me ?
I tried to use the following function:
Public Function IncreaseSalesPricewith2Percent()
Dim db As DAO.Database
Set db = CurrentDb
db.Execute "UPDATE Products WHERE SalesPrice = SalesPrice * 1.2"
Set db = Nothing
End Function

Nov 12 '05 #2
Use an update query like
UPDATE Products SET Products .SalesPrice = [SalesPrice]*1.02;

Make sure you multiply by 1.02. The 1.2 you suggest is a 20% uplift. The
chancellor would not like it

HTH

Phil
"Johm" <ke**@abv.bg> wrote in message
news:24**************************@posting.google.c om...
Update filed with percentage

In the table Products we have to update the field SalesPrice with 2
percents . We have to increase all the Sales Prices of our products
with 2 percent.Our idea is to multiply the price with 1.2 for all the
products. However, I get the message " Syntax error in update
statement.
Could someone help me ?
I tried to use the following function:
Public Function IncreaseSalesPricewith2Percent()
Dim db As DAO.Database
Set db = CurrentDb
db.Execute "UPDATE Products WHERE SalesPrice = SalesPrice * 1.2"
Set db = Nothing
End Function

Nov 12 '05 #3
WHERE clauses are used to select the records, not update the value. The SET
clause is used to update the value.

Here's some SQL from a Query created using the QueryBuilder that works on a
table in one of my test databases:

UPDATE tblSomeNums SET tblSomeNums.AFloat = [AFloat]*1.5;

Larry Linson
Microsoft Access MVP
"Johm" <ke**@abv.bg> wrote in message
news:24**************************@posting.google.c om...
Update filed with percentage

In the table Products we have to update the field SalesPrice with 2
percents . We have to increase all the Sales Prices of our products
with 2 percent.Our idea is to multiply the price with 1.2 for all the
products. However, I get the message " Syntax error in update
statement.
Could someone help me ?
I tried to use the following function:
Public Function IncreaseSalesPricewith2Percent()
Dim db As DAO.Database
Set db = CurrentDb
db.Execute "UPDATE Products WHERE SalesPrice = SalesPrice * 1.2"
Set db = Nothing
End Function

Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: rrh | last post by:
I am trying to update a field in one table with data from another table. The problem I'm running into is I need to base the update on a range of data in the 2nd table. Table 1 has: date field...
3
by: BlackFireNova | last post by:
This concerns an Access 2002 (XP) database. There are two fields, "Notes" (Memo Field) and "Notes Update" on a form (among others) which I am concerned with here. Problem: I need to be able...
3
by: Bill Clark | last post by:
I have about 20,000 records pulled from Excel that I need to update. What I need to do is run an update query that bascially says: If a field is null, update it with the previous record value of...
8
by: Maxi | last post by:
There is a lotto system which picks 21 numbers every day out of 80 numbers. I have a table (name:Lotto) with 22 fields (name:Date,P1,P2....P21) Here is the structure and sample data: ...
6
by: Matt | last post by:
I'm having difficulty with trying to update a Access memo field through an SQL statement where the value I'm trying to pass is longer than 255 characters. The field is being truncated. I'm using...
2
by: Brett | last post by:
My database has 2 tables: Table1 & Table2. If a field is not null on a record in table2, then the not null fields in table1 that correspond to the records in table1 needs to be updated to match the...
16
by: Ian Davies | last post by:
Hello Needing help with a suitable solution. I have extracted records into a table under three columns 'category', 'comment' and share (the category column also holds the index no of the record...
1
by: luckyerdai | last post by:
I have a table, what I need to do is if Field 1= a, field 2=b, field 3=c, then field 4 update to xxxx; iif Field 1= a, field 2=b, field 3=d, then field 4 update to xxxxxx, if Field 1= z, field...
2
by: John Kotuby | last post by:
Hi all, Maybe this belongs in the Full Text group but I am writing an ASP.NET application with a SQL Server 2005 backend, so I am posing the question here. I have been using fulltext search...
4
by: hapnendad | last post by:
In the question statement below Field names are in and variables are in (). All fields referenced are in what I have named the ‘PAR’ Table. Using MS Access 2003, I am working on a project...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.