473,394 Members | 2,160 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,394 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 2362
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.