473,326 Members | 2,128 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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 2358
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Venkata C | last post by:
Hi! Does anyone here know of a way to goad DB2 into converting a correlated subquery to a non-correlated one? Does DB2 ever do such a conversion? We have a query of the form SELECT .. FROM A...
2
by: Jur Schagen | last post by:
I have this weird sorting problem. I have a report that is based on a query. The query is sorted on field A, and if I run it seperately it is decently sorted on that field. However, if I call the...
1
by: Mike MacSween | last post by:
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. ...
4
by: Philippe | last post by:
Hello, I encounter a problem that I cannot solve myself... The problem is the following: I make a table: several records: the first field is always a number, the following field is always...
3
by: Mat N | last post by:
Hi, I've been trying to work out how to create a report based on crosstab query for which the number of fields is variable. For example in a situation where you show customer billing by year in...
5
by: Terri | last post by:
The following query will give me the top ten states with the most callers. SELECT TOP 10 Count(Callers.CallerID) AS CountOfCallerID, Callers.State FROM Callers GROUP BY Callers.State ORDER BY...
2
by: scott.k.fraley | last post by:
....and the SELECT thats trying to pull from said Query doesn't like it one bit! ;) I'm working on this project (in Access 2002) and there is a report who's RecordSource is the following...
5
by: steven.fafel | last post by:
I am running 2 versions of a correlated subquery. The two version differ slightly in design but differ tremendously in performance....if anyone can answer this, you would be awesome. The "bad"...
4
by: lorirobn | last post by:
Hi, I have a report displaying items that are missing from a room. I created 2 queries, the first getting the items IN the room, and the second being an "unmatched" query that references the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.