Syntax error - please help a newbie

pcc

Well-known Member
Joined
Jan 21, 2003
Messages
1,366
Office Version
  1. 2021
Platform
  1. Windows
I am very new to Access and SQL. I have this code in a query, but when I try to save the query, I get a 'syntax error (missing operator)' message.
All of the field and table names are OK, so what have I missed?
Code:
SELECT s.PrjDef, s.PrjType, s.ActType, s.CCntr, s.Hours, s.yr, s.ap, s.inorsub = 
CASE 
WHEN s.inorsub = 'I' then 'Inhouse' 
ELSE  'Subcon' 
END 
FROM sapsummary AS s WHERE 1=1 ;
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hi pcc

Access SQL does not support CASE expressions. You will need to determine variables outside of the SQL statement.

Also, as far as I am aware, your FROM TableName AS ?? is not supported in Access SQL. You must qualify the fields before the FROM bit (sapsummary.PrjDef, etc.).

anvil19
:eek:
 
Upvote 0
Thanks for reply. I think you are right regarding the CASE statement so I am looking at other ways (SWITCH function maybe?). With regard to the second point, the tablename AS statement seems to work OK for me so I'll stick with it.
Thanks for your time.
Cheers
 
Upvote 0

Forum statistics

Threads
1,221,672
Messages
6,161,199
Members
451,688
Latest member
Gregs44132

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