Avatar of shieldsco
shieldsco
Flag for United States of America asked on

MS Access Syntax Error

I'm using the following code and receiving Access error code:

Error

SELECT
CASE 
WHEN [tblConsolidated].[Appeal Category L3] IN
('180 MEDICAL INC',
'180 MEDICAL INC',
'180 Medical Inc.',
'180 Medical, Inc',
'180 MEDICAL, INC.')
THEN '180 MEDICAL INC'
Else [tblConsolidated].[Appeal Category L3];

Open in new window

Microsoft AccessSQL

Avatar of undefined
Last Comment
slightwv (䄆 Netminder)

8/22/2022 - Mon
Norie

As far as I know you can't use CASE WHEN in Access SQL, what you could try instead is an Iif statement.

Iif([tblConsolidated].[Appeal Category L3] IN ('180 MEDICAL INC', '180 MEDICAL INC', '180 Medical Inc.', '180 Medical, Inc', '180 MEDICAL, INC.'), '180 MEDICAL INC'
, [tblConsolidated].[Appeal Category L3])

Open in new window


Or perhap simpler.
IIf(UCase(Replace(Replace(Replace([tblConsolidated].[Appeal Category L3], ',', ''), '.', ''), ' ', '')) = '180MEDICALINC', '180 MEDICAL INC', [tblConsolidated].[Appeal Category L3])

Open in new window

shieldsco

ASKER
receiving the following

Image
slightwv (䄆 Netminder)

Do you need all the checks?

See if this works:
SELECT  ucase(replace(replace([Appeal Category L3],'.',''),',','')) from tblConsolidated;
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
slightwv (䄆 Netminder)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
shieldsco

ASKER
same error
shieldsco

ASKER
Thanks
slightwv (䄆 Netminder)

Still not seeing he need for the list when you can just replace the punctuation and get the same results.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
slightwv (䄆 Netminder)

I think Norie should get an accepted solution sine it was their IIF.  I just helped with the syntax.