Re: Union query not working properly if no records exist

From: Tony (anonymous_at_discussions.microsoft.com)
Date: 09/20/04


Date: Mon, 20 Sep 2004 03:56:31 -0700


Hi John,

Thank you for your reply. Apologies for not getting back
sooner...I have just returned to work this morning.
You are correct - I've had a good look at the problem and
the problem itself is not being generated by the union
query (which I had mistakenly thought) but is instead
being generated by a cross tab query. The cross tab pull
together all records for all tables but if no records
exist in a certain table then it doesn't show a column
heading for that table. The union query then fails
to "work" correctly as it cannot retrieve a desired record
count from the offending table.

For example, if no records exist in a table called
tblMeasure56B, the union query returns the following error
problem...

The Microsoft Database engine does not
recognize 'qryAllFarmersAndMeasures'_Crosstab.[5.6B] as a
valid field name or expression.

Is there a workaround for this problem - maybe I am doing
things back-to-front or upside down. I'm not really sure
as fairly new to working with databases.

Grateful for your help

Regards

Tony
BTW, I have copied the SQL of the cross tab just in case
you need to see it.

TRANSFORM Count(qryAllFamersAndMeasures.FarmerID) AS
CountOfFarmerID
SELECT qryAllFamersAndMeasures.Measure,
qryAllFamersAndMeasures.Amount,
qryAllFamersAndMeasures.Surname,
qryAllFamersAndMeasures.FarmerID, Count
(qryAllFamersAndMeasures.FarmerID) AS [Total Of FarmerID]
FROM qryAllFamersAndMeasures
GROUP BY qryAllFamersAndMeasures.Measure,
qryAllFamersAndMeasures.Amount,
qryAllFamersAndMeasures.Surname,
qryAllFamersAndMeasures.FarmerID
PIVOT qryAllFamersAndMeasures.Measure;

>-----Original Message-----
>On Fri, 17 Sep 2004 02:02:44 -0700, "Tony"
><anonymous@discussions.microsoft.com> wrote:
>
>>I have designed a Union query (SQL copied below) to
enable
>>me to produce stats from the major tables in my DB. To
>>get it to work properly I have to put a test record
>>(blank) into certain tables for it to work correctly.
How
>>can I get it to work properly if no records exist in
some
>>tables, which is currently the case.
>
>What is 'not working properly'? What result do you
expect, and what
>result are you getting?
>
>A UNION query in which one of the SELECT clauses returns
no records
>"works" in the sense that it returns all the records from
all the
>other SELECTs; there is no error and no record returned
for the empty
>recordset. Is this not what you expect or need?
>
> John W. Vinson[MVP]
> Join the online Access Chats
> Tuesday 11am EDT - Thursday 3:30pm EDT
> http://community.compuserve.com/msdevapps
>.
>



Relevant Pages

  • Union query retrieves 1000 records only
    ... I made a union query that I then display as a cross tab. ... Prev by Date: ...
    (microsoft.public.access.queries)
  • Access export to excel bug
    ... My apologies for crossposting this, but I did not get any response in ... UNION query does not export to excel successfully and prompts the user ...
    (comp.databases.ms-access)