Need help with access query...

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Hi I need help with access query...

Current query does not work...
I am trying to use Update query to update the record in table if TOTALSALES"<40 then TOTALSALES records value = TOTALSALES + 1


Code:
[/FONT]
[FONT=Courier New]UPDATE rawdata SET rawdata.TOTALSALES = "TOTALSALES" +  1
WHERE (("TOTALSALES"<40));


Please advice.
Pedie
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Why is TOTALSALES in quotes?

It is a field isn't it?

If it is then it should definitely not have quotes, you should be able to use it on it's own.

Mind you wrapping it in [] wouldn't to any harm.
 
Upvote 0
Hi Norie, total Sales in the number from 20 - 190
No blanks.
I want query to check the Total Sales Col then add 1 if Total Sales < 40


Thanks Norie
 
Upvote 0
That still doesn't explain why TOTALSALES is in quotes.

What is TOTALSALES? A field? The sum of another field (perhaps SALES)?

Try this:

UPDATE RawData SET RawData.TOTALSALES = [rawdata].[TOTALSALES]+1
WHERE (((RawData.TOTALSALES)<40));
 
Upvote 0
just to reinforce Norie's instruction, it never hurts to bracket table and column names:
Code:
UPDATE [rawdata] 
SET [rawdata].[TOTALSALES] = [TOTALSALES] +  1
WHERE [TOTALSALES] < 40;

You can leave them off if there are no spaces in the table or column names:
Code:
UPDATE rawdata 
SET rawdata.TOTALSALES = TOTALSALES +  1
WHERE TOTALSALES < 40;

If any table or column has a space you must bracket it:
Code:
SELECT Table1.[Field 1] From Table;
 
Upvote 0
pedie

Did Access add the quotes itself when you typed TOTALSALES in the update to section?
 
Upvote 0
Pedie

I actually forgot that Access sometimes did that, and it doesn't if you specify the table name which you need to do with some databases.
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,834
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top