Connecting Tech Pros Worldwide Help | Site Map

update field

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 12th, 2005, 09:57 PM
Johm
Guest
 
Posts: n/a
Default 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

  #2  
Old November 12th, 2005, 09:57 PM
Pavel Romashkin
Guest
 
Posts: n/a
Default Re: update field

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:[color=blue]
>
> 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[/color]
  #3  
Old November 12th, 2005, 09:57 PM
Phil Stanton
Guest
 
Posts: n/a
Default Re: update field

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" <keks@abv.bg> wrote in message
news:2402261c.0404210812.4f2f4aeb@posting.google.c om...[color=blue]
> 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[/color]


  #4  
Old November 12th, 2005, 09:57 PM
Larry Linson
Guest
 
Posts: n/a
Default Re: update field

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" <keks@abv.bg> wrote in message
news:2402261c.0404210812.4f2f4aeb@posting.google.c om...[color=blue]
> 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[/color]


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.