Ms Excel cannot retrieve Union Query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have crate a union query in Ms Access XP to combine 2 tables Customer &
Vendor.

Below is how the query looks like

SELECT strCustomerID as strID, strCompanyName, "Customer" as strType
FROM tblCustomer
UNION SELECT strVendorID as strID, strCompanyName, "Vendor" as strType
FROM tblVendor;

It can run properly in Ms Access but when I try to import the data from Ms
Access
using Ms Excel's Import External Data | New Database Query, MS Excel
complaints
Too few parameters. Expected 2.

Anyone knows what when wrong?


Thank You
 
Not sure if this will help but try:
SELECT strCustomerID as strID, strCompanyName, "Customer" as strType
FROM tblCustomer
UNION ALL
SELECT strVendorID, strCompanyName, "Vendor"
FROM tblVendor;
 
What else have you tried? What happens if you remove the "as..." aliases?
What happens if you remove the Customer and Vendor strings?
 
I think I found out what's wrong.

The cause of the problem lies in Ms Excel. It cannot support a query with
calculated/derived field.

However if you do it using Ms Query from within Ms Excel you can do any
union query with any number calculated fields.
 
Back
Top