Using DMin in Query to create a record set (1 Viewer)

Danick

Registered User.
Local time
Today, 04:40
Joined
Sep 23, 2008
Messages
351
Trying to create a recordset via a query where all records shown with the lowest item number record. I've tried this, but it's not working.

Code:
DMin("ItemNo","Findings",[Findings].[ItemNo])

So for example, I have this in the table


1696362202468.png


Any ideas how to fix it?
 

plog

Banishment Pending
Local time
Today, 03:40
Joined
May 11, 2011
Messages
11,648
First, your DMIN is only part of the code, I'd really need to know the entire code to really help you. With that said, your DMin is essentially constant--it is set to find the lowest ItemNo in your table. Not the lowest ItemNo among a subset of records, but the lowest ItemNo in the entire table. So, its going to find 01 and only bring back those with ItemNo=01. You need to fix your Dmin so that it takes into account the subset of records it should be operating on--not the entire table.

Again though, I don't know if Dmin is the correct way to achieve this. I think a correlated subquery might be more efficient.
 

Danick

Registered User.
Local time
Today, 04:40
Joined
Sep 23, 2008
Messages
351
First, your DMIN is only part of the code, I'd really need to know the entire code to really help you. With that said, your DMin is essentially constant--it is set to find the lowest ItemNo in your table. Not the lowest ItemNo among a subset of records, but the lowest ItemNo in the entire table. So, its going to find 01 and only bring back those with ItemNo=01. You need to fix your Dmin so that it takes into account the subset of records it should be operating on--not the entire table.

Again though, I don't know if Dmin is the correct way to achieve this. I think a correlated subquery might be more efficient.
Thanks for pointing me in the right direction. I managed to get this to work using a correlated subquery as explained here:

 

Users who are viewing this thread

Top Bottom