Getting syntax error while running a query in Access. The same query works in Power Query.

sandy_xpac

New Member
Joined
Jul 13, 2016
Messages
33
I am trying to run the below query in Access and I get the following error: Syntax error (missing operator) in query expression '(case when ModeCode in ('B','G') and claimpaiddate is not null then 'Paid' when ModeCode not in ('B','G') and ClaimStatus not like 'D%' and claimpaiddate is not null then 'Paid' else 'Denied' end),


select cd.PlanID as "Plan ID",
PlanName,
ApptDate,
PickupState,
PickupCounty,
ModeCode,
VendorName,
GroupID,
TripLegID,
Triplegstatus,
ClaimStatus,
(case when ModeCode in ('B','G') and claimpaiddate is not null then 'Paid'
when ModeCode not in ('B','G') and ClaimStatus not like 'D%' and claimpaiddate is not null then 'Paid' else 'Denied' end) as PaidorDenied,
ClaimPaidDate,
pp.ClientName,
pp.PlanState,
pp.Population,
pp.Status,
ServiceMonth,
ServiceYear,
Sum(TripLegs) as "Legs",
Sum(TripLegCost) as "Cost",
Sum(TripMiles) as "Miles"
from reports.dbo.Datamart_ClaimDetails cd JOIN
reports.dbo.pricing_PlanGroupings pp on cd.PlanID=pp.Plan_Code
where apptdate >= '01/01/2017'
Group by cd.PlanID,
PlanName,
ApptDate,
PickupState,
PickupCounty,
ModeCode,
VendorName,
GroupID,
TripLegID,
Triplegstatus,
ClaimStatus,
(case when ModeCode in ('B','G') and claimpaiddate is not null then 'Paid'
when ModeCode not in ('B','G') and ClaimStatus not like 'D%' and claimpaiddate is not null then 'Paid' else 'Denied' end),
ClaimPaidDate,
ServiceMonth,
ServiceYear,
pp.ClientName,
pp.PlanState,
pp.Population,
pp.Status
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Access doesn't have Case...When, I think you might want to look at using Iif.

Perhaps something like this.

Iif(ModeCode In ('B', 'G') And Not IsNull(claimpaiddate), 'Paid', Iif(Not Claimstatus Like 'D*' and Not IsNull(claimpaiddate), 'Paid', 'Denied'))
 
Upvote 0
Thanks now its giving me error "syntax error in FROM clause" :(

Sorry I am not familiar with access. I use crystal reports and power BI
 
Upvote 0
I tried the above but still Syntax error FROM clause

from reports.dbo.Datamart_ClaimDetails cd JOIN
reports.dbo.pricing_PlanGroupings pp on cd.PlanID=pp.Plan_Code
 
Upvote 0
Code:
from 
  reports.dbo.Datamart_ClaimDetails as cd 
  JOIN
  reports.dbo.pricing_PlanGroupings as pp 
    on 
    cd.PlanID = pp.Plan_Code
 
Upvote 0
Code:
from 
  reports.dbo.Datamart_ClaimDetails as cd 
  JOIN
  reports.dbo.pricing_PlanGroupings as pp 
    on 
    cd.PlanID = pp.Plan_Code


Thnak you James. It still gives me "Syntax error in FROM clause"


select cd.PlanID as "Plan ID",
pp.PlanName as "Plan Name",
ApptDate,
PickupState as "Pickup State",
PickupCounty,
ModeCode as "Mode Code",
VendorName as "Vendor Name",
GroupID,
TripLegID,
Triplegstatus,
ClaimStatus,
Iif(ModeCode In ('B', 'G') And Not IsNull(claimpaiddate), 'Paid', Iif(Not Claimstatus Like 'D*' and Not IsNull(claimpaiddate), 'Paid', 'Denied')),
ClaimPaidDate,
pp.ClientName as "Client Name",
pp.PlanState,
pp.Population,
pp.Status,
pp. [Client Type],
pp. [Business Type],
ServiceMonth,
ServiceYear,
Sum(TripLegs) as "Legs",
Sum(TripLegCost) as "Cost",
Sum(TripMiles) as "Miles"
from
reports.dbo.Datamart_ClaimDetails as cd
JOIN
reports.dbo.pricing_PlanGroupings as pp
on
cd.PlanID = pp.Plan_Code
where apptdate >= #01/01/2017#
Group by cd.PlanID,
pp.PlanName,
ApptDate,
PickupState,
PickupCounty,
ModeCode,
VendorName,
GroupID,
TripLegID,
Triplegstatus,
ClaimStatus,
Iif(ModeCode In ('B', 'G') And Not IsNull(claimpaiddate), 'Paid', Iif(Not Claimstatus Like 'D*' and Not IsNull(claimpaiddate), 'Paid', 'Denied')),
ClaimPaidDate,
ServiceMonth,
ServiceYear,
pp.ClientName,
pp.PlanState,
pp.Population,
pp.[Client Type],
pp.[Business Type],
pp.Status
 
Upvote 0
so these are MS SQL Server tables or Oracle tables ?

and you have them linked or imported in Access

if linked, how ?

and is this a regular Access query or a passthrough query
 
Upvote 0

Forum statistics

Threads
1,215,227
Messages
6,123,739
Members
449,116
Latest member
alexlomt

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