473,885 Members | 2,533 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.EventN ame, qryProduction.P rodName, qryEvent.ProdID ,
qryEvent.StartD ate, qryEvent.StartT ime, (SELECT First(qryEvent. StartDate)
FROM qryEvent WHERE qryEvent.ProdID = qryProduction.P rodID) AS ProdDate
FROM qryEvent INNER JOIN qryProduction ON qryEvent.ProdID =
qryProduction.P rodID
WHERE (((qryEvent.Sta rtDate)>=Date() Or (qryEvent.Start Date) 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 2417
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.EventN ame, qryProduction.P rodName, qryEvent.ProdID ,
qryEvent.StartD ate, qryEvent.StartT ime, (SELECT First(qryEvent. StartDate)
FROM qryEvent WHERE qryEvent.ProdID = qryProduction.P rodID) AS ProdDate
FROM qryEvent INNER JOIN qryProduction ON qryEvent.ProdID =
qryProduction.P rodID
WHERE (((qryEvent.Sta rtDate)>=Date() Or (qryEvent.Start Date) 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:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

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

iQA/AwUBQG6JwoechKq OuFEgEQJEWACfUf Eh7ZY4xGugFiaqs 5A7rTXIaFAAoOwK
93MxH/jq3uNs1cnb8mdGR IeV
=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
5110
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 WHERE EXISTS (SELECT 'X' FROM B, C WHERE B.COL1 = A.COL1 AND B.COL2 = A.COL2
2
2241
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 report, it is sorted on field B. I am not using the "Order by"-property of the report; in fact, if I say "Field A" in it, the report is STILL sorted on field B. Any suggestions?
1
328
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. So this as a query (I've stripped out surplus fields): SELECT qryEvent.EventName, qryProduction.ProdName, qryEvent.ProdID,
4
1455
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 an address
3
5233
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 the following format: Customer 2000 2001 2002 Bill 103 10 205 Frank 12 50
5
6641
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 Count(Callers.CallerID) DESC; How can I return the same result set, the top ten states, but sort the result set by state.
2
2548
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 SELECT; SELECT xTab.FirstOfPRIORITZTN_STATUS_NAME, xTab., iif(IsNull( xTab. ), 0, xTab.) AS ,
5
2250
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" query attempts to build a result set using a correlated subquery. The part causing the error is that the correlated subquery is part of a derived table (joining 3 tables). Trying to run the query takes a long time and the more records in the...
4
3142
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 first query where Item is Null. I use a subreport for the details, and the results display correctly. However, the Report_Details event of the subreport is executed about 2 or 3 times more than I would expect (I think 3 times when I have a
0
9956
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9799
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11172
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10770
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10871
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7987
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4627
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4235
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3245
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.