469,342 Members | 5,582 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,342 developers. It's quick & easy.

Correlated sub query crashing report/not allowed sorting

tblProductions one to many to tblEvents

tblEvents contains StartDate

I want a report where the data are grouped by tblProductions.ProdID, and
sorted by the earliest date in each Production.

So this as a query (I've stripped out surplus fields):

SELECT qryEvent.EventName, qryProduction.ProdName, qryEvent.ProdID,
qryEvent.StartDate, qryEvent.StartTime, (SELECT First(qryEvent.StartDate)
FROM qryEvent WHERE qryEvent.ProdID = qryProduction.ProdID) AS ProdDate
FROM qryEvent INNER JOIN qryProduction ON qryEvent.ProdID =
qryProduction.ProdID
WHERE (((qryEvent.StartDate)>=Date() Or (qryEvent.StartDate) Is Null));

This gives me what I want, nearly.

1. I can't set an Order By on ProdDate, I get Syntax Error if I try.

2. Presumably related, if in a report based on this (WITHOUT an order by in
the query) I get a crash if I try to do anything useful in Sorting and
Grouping with ProdDate. Basically when I move from design to preview I get a
'this will reset break mode...' or whatever that message is. Can't see a VBA
module open or anywhere.

Any ideas why this is happening, or a better approach (not that I can really
see what's wrong with mine!)?

Cheers, Mike MacSween
Nov 12 '05 #1
1 2122
Mike MacSween wrote:
tblProductions one to many to tblEvents

tblEvents contains StartDate

I want a report where the data are grouped by tblProductions.ProdID, and
sorted by the earliest date in each Production.

So this as a query (I've stripped out surplus fields):

SELECT qryEvent.EventName, qryProduction.ProdName, qryEvent.ProdID,
qryEvent.StartDate, qryEvent.StartTime, (SELECT First(qryEvent.StartDate)
FROM qryEvent WHERE qryEvent.ProdID = qryProduction.ProdID) AS ProdDate
FROM qryEvent INNER JOIN qryProduction ON qryEvent.ProdID =
qryProduction.ProdID
WHERE (((qryEvent.StartDate)>=Date() Or (qryEvent.StartDate) Is Null));

This gives me what I want, nearly.

1. I can't set an Order By on ProdDate, I get Syntax Error if I try.

2. Presumably related, if in a report based on this (WITHOUT an order by in
the query) I get a crash if I try to do anything useful in Sorting and
Grouping with ProdDate. Basically when I move from design to preview I get a
'this will reset break mode...' or whatever that message is. Can't see a VBA
module open or anywhere.

Any ideas why this is happening, or a better approach (not that I can really
see what's wrong with mine!)?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
1. Don't use First() - I've never had it work as anticipated. Perhaps
you want Min() to get the first date?

2. I've found that Access (JET) queries that have a correlated subquery
in the SELECT clause do not work in reports. I've had to use Domain
Aggregate functions instead (i.e., DMin).

3. If the query is going to be used in a report don't use the ORDER BY
clause. Sort the columns using the report's Group/Sort dialog box.

If you must sort the query use the columns ordinal position instead of
the sort column's expression in the ORDER BY clause. E.g. (using your
SELECT clause, above):

ORDER BY 6

This will sort, ascending, the results by the ProdDate column: the 6th
column in the SELECT clause.

- --
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQG6JwoechKqOuFEgEQJEWACfUfEh7ZY4xGugFiaqs5A7rT XIaFAAoOwK
93MxH/jq3uNs1cnb8mdGRIeV
=Phfv
-----END PGP SIGNATURE-----

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Jur Schagen | last post: by
4 posts views Thread by Philippe | last post: by
5 posts views Thread by steven.fafel | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by haryvincent176 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.