Connecting Tech Pros Worldwide Help | Site Map

Acc2003: Problem with UNION query in subreport?

 
LinkBack Thread Tools Search this Thread
  #1  
Old March 12th, 2006, 01:35 AM
planetthoughtful
Guest
 
Posts: n/a
Default Acc2003: Problem with UNION query in subreport?

Hi All,

I'd like to place a subreport onto a report that draws its records from
a UNION query.

When I design the query and view the records all looks fine. However,
when I put the query as the subreport's data source and open it, Access
complains that Jet can't find the table, and then when I open up the
query itself to look at the SQL, it appears all mangled.

The query def is as follows:

SELECT recdate, orderid, outcontext, outtext, reviewdate, recstatus
FROM (SELECT recdate, orderid, iif(context=1, "Call", iif(context=2,
"Email", iif(context=3,"Check Order",iif(context=4,"Speak to","Find
out")))) as outcontext, nextaction as outtext, reviewdt, IIF(status=1,
"Outstanding", "Resolved") as recstatus FROM tbl_ordernextactions
UNION
SELECT recdate, orderid,iif(notetype=1, "Outstanding", "Resolved") as
outcontext, note as outtext, "" as reviewdate, "" as recstatus FROM
tbl_ordernotes) AS unquery order by recdate

When I try and attach it to the subreport and open it, it gets mangled
to:

SELECT recdate, orderid, outcontext, outtext, reviewdt, recstatus
FROM [SELECT recdate, orderid, iif(context=1, "Call", iif(context=2,
"Email", iif(context=3,"Check Order",iif(context=4,"Speak to","Find
out")))) as outcontext, nextaction as outtext, reviewdt, IIF(status=1,
"Outstanding", "Resolved") as recstatus FROM tbl_o] AS unquery
ORDER BY recdate;

Is this a bug, or a limitation of Acc2003, or am I doing something
wrong in my query def?

Any help appreciated!!

Much warmth,

planetthoughtful
---
"Lost in thought"
http://www.planetthoughtful.org


  #2  
Old March 12th, 2006, 01:55 AM
planetthoughtful
Guest
 
Posts: n/a
Default Re: Acc2003: Problem with UNION query in subreport?

Okay, it appears it is a limitation of Acc2003, in that it doesn't seem
to like UNION queries embedded in a subquery. A little odd - most other
db environments would cope with this, but now that I've removed the
subquery component and I'm providing ordering via the subreport, all
seems to work okay.

Much warmth,

planetthoughtful
---
"Lost in thought"
http://www.planetthoughtful.org

  #3  
Old March 12th, 2006, 11:15 PM
david epsom dot com dot au
Guest
 
Posts: n/a
Default Re: Acc2003: Problem with UNION query in subreport?

Yes, as others have pointed out before me :~), Access will
tend to mangle "(select ...)" into "[select ...]."
(Note the full stop after the final square bracket)

[]. was the Jet 3.5 format, but never properly supported.
() is the Jet 4.0 format, but Access will rewrite it
if given a chance.

For very simple sub-selects, I think that this might not
matter. For more complex sub-selects, you need to write
the sub-select as a stored query. For dynamic SQL, where
Access doesn't have a chance to re-write the SQL, you
can use anything that works.

(david)

"planetthoughtful" <planetthoughtful@gmail.com> wrote in message
news:1142129931.284872.50080@e56g2000cwe.googlegro ups.com...[color=blue]
> Hi All,
>
> I'd like to place a subreport onto a report that draws its records from
> a UNION query.
>
> When I design the query and view the records all looks fine. However,
> when I put the query as the subreport's data source and open it, Access
> complains that Jet can't find the table, and then when I open up the
> query itself to look at the SQL, it appears all mangled.
>
> The query def is as follows:
>
> SELECT recdate, orderid, outcontext, outtext, reviewdate, recstatus
> FROM (SELECT recdate, orderid, iif(context=1, "Call", iif(context=2,
> "Email", iif(context=3,"Check Order",iif(context=4,"Speak to","Find
> out")))) as outcontext, nextaction as outtext, reviewdt, IIF(status=1,
> "Outstanding", "Resolved") as recstatus FROM tbl_ordernextactions
> UNION
> SELECT recdate, orderid,iif(notetype=1, "Outstanding", "Resolved") as
> outcontext, note as outtext, "" as reviewdate, "" as recstatus FROM
> tbl_ordernotes) AS unquery order by recdate
>
> When I try and attach it to the subreport and open it, it gets mangled
> to:
>
> SELECT recdate, orderid, outcontext, outtext, reviewdt, recstatus
> FROM [SELECT recdate, orderid, iif(context=1, "Call", iif(context=2,
> "Email", iif(context=3,"Check Order",iif(context=4,"Speak to","Find
> out")))) as outcontext, nextaction as outtext, reviewdt, IIF(status=1,
> "Outstanding", "Resolved") as recstatus FROM tbl_o] AS unquery
> ORDER BY recdate;
>
> Is this a bug, or a limitation of Acc2003, or am I doing something
> wrong in my query def?
>
> Any help appreciated!!
>
> Much warmth,
>
> planetthoughtful
> ---
> "Lost in thought"
> http://www.planetthoughtful.org
>[/color]


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.