Union query to Excel from Access

H

Harley Feldman

I have an Access union query (below) which I cannot execute via ODBC from Excel (it works in Access). The message that I receive is Too few parameters (3). Typically this message comes up when the field names do not match. Since the field names were displayed from the Microsoft Query driver, and I just double-clicked them, I cannot see how they could be missing. Also, I am able to read in each table separately into cells just below the previous data.

I even tried creating a new query which just loads the existing query and its values, and then accessing it. I wound up with the same results.

Any ideas?

Harley

SELECT EventMaster.PatientKey, [SGPatients Meeting DRSG Criteria].EventPkey, EventMaster.Date, EventPatAssessScore.ObservationDate, EventPatAssessScore.Type, EventPatAssessScore.StdScore AS [Value]
FROM ([SGPatients Meeting DRSG Criteria] INNER JOIN EventMaster ON [SGPatients Meeting DRSG Criteria].EventPkey = EventMaster.EventPKey) INNER JOIN EventPatAssessScore ON [SGPatients Meeting DRSG Criteria].EventPkey = EventPatAssessScore.EventPKey
GROUP BY EventMaster.PatientKey, [SGPatients Meeting DRSG Criteria].EventPkey, EventMaster.Date, EventPatAssessScore.ObservationDate, EventPatAssessScore.Type, EventPatAssessScore.StdScore
HAVING (((EventPatAssessScore.ObservationDate)>[EventMaster].[Date]))
UNION
SELECT DISTINCT DRSGGripInjured.PatientKey, DRSGGripInjured.EventPKey, DRSGGripInjured.Date, DRSGGripInjured.ObservationDate, "Grip Strength (% opposite)" AS Type, IIf([DRSGGripNormal].[Value]=0,0,[DRSGGripInjured].[Value]/[DRSGGripNormal].[Value]) AS [Value]
FROM DRSGGripInjured INNER JOIN DRSGGripNormal ON (DRSGGripInjured.PatientKey = DRSGGripNormal.PatientKey) AND (DRSGGripInjured.EventPKey = DRSGGripNormal.EventPKey) AND (DRSGGripInjured.Date = DRSGGripNormal.Date) AND (DRSGGripInjured.ObservationDate = DRSGGripNormal.ObservationDate) AND (DRSGGripInjured.Side = DRSGGripNormal.Side)
UNION
SELECT DISTINCT DRSGPronationInjured.PatientKey, DRSGPronationInjured.EventPKey, DRSGPronationInjured.Date, DRSGPronationInjured.ObservationDate, "Pronation (% opposite)" AS Type, IIf([DRSGPronationNormal].[Value]=0,0,[DRSGPronationInjured].[Value]/[DRSGPronationNormal].[Value]) AS [Value]
FROM DRSGPronationInjured INNER JOIN DRSGPronationNormal ON (DRSGPronationInjured.Side = DRSGPronationNormal.Side) AND (DRSGPronationInjured.ObservationDate = DRSGPronationNormal.ObservationDate) AND (DRSGPronationInjured.Date = DRSGPronationNormal.Date) AND (DRSGPronationInjured.EventPKey = DRSGPronationNormal.EventPKey) AND (DRSGPronationInjured.PatientKey = DRSGPronationNormal.PatientKey)
UNION SELECT DISTINCT DRSGSupinationInjured.PatientKey, DRSGSupinationInjured.EventPKey, DRSGSupinationInjured.Date, DRSGSupinationInjured.ObservationDate, "Supination (% opposite)" AS Type, IIf([DRSGSupinationNormal].[Value]=0,0,[DRSGSupinationInjured].[Value]/[DRSGSupinationNormal].[Value]) AS [Value]
FROM DRSGSupinationInjured INNER JOIN DRSGSupinationNormal ON (DRSGSupinationInjured.PatientKey = DRSGSupinationNormal.PatientKey) AND (DRSGSupinationInjured.EventPKey = DRSGSupinationNormal.EventPKey) AND (DRSGSupinationInjured.Date = DRSGSupinationNormal.Date) AND (DRSGSupinationInjured.ObservationDate = DRSGSupinationNormal.ObservationDate) AND (DRSGSupinationInjured.Side = DRSGSupinationNormal.Side);
 
A

Andi Mayer

I have an Access union query (below) which I cannot execute via ODBC from Excel (it works in Access). The message that I receive is Too few parameters (3). Typically this message comes up when the field names do not match. Since the field names were displayed from the Microsoft Query driver, and I just double-clicked them, I cannot see how they could be missing. Also, I am able to read in each table separately into cells just below the previous data.

I even tried creating a new query which just loads the existing query and its values, and then accessing it. I wound up with the same results.

Any ideas?

First: turn off html (it is unreadably in a real newsreader)

it could be your field: Date this is a reserved VBA-word
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top