Criteria help

gguy

Registered User.
Local time
Today, 15:52
Joined
Jun 27, 2002
Messages
104
I have a query that shows only the last record entered in my table for each account number. The table has lots of records for each account number but this query only shows the last record entered for each account.
For the sake of this example, lets say, I have ten account numbers and when I run the query I get ten records.
I want to produce a report from this query but I need to show one field in the record that is true/false. Every time I add the true/false field into the query I get 20 records. For each account I get one that is true and one that is false.
I don't care whether the last record for the account was true or false, I just want the last record and to show the true/false value for that last record. GGuy
 
Is this true/false field originating in the same table as the rest of your fields in the query? Sounds to me that it's from a different table and you don't have a proper link/relationship set up between the two tables.

I apologise if this is a no-brainer and your dilemma is more advanced than this. (I'm new to these boards.) Otherwise, hope this helps.
 
gguy -

Do you have an autonumber key or a time/date stamp in your table? If so, here is one method. It's not very clean but it will do what you want. It takes two queries.

Step 1:
SELECT Max(Table1.ID) AS MaxOfID, Table1.AccountNumber
FROM Table1
GROUP BY Table1.AccountNumber;

Step 2:
SELECT Table1.ID, Table1.AccountNumber, Table1.TorF
FROM Query1 INNER JOIN Table1 ON Query1.MaxOfID = Table1.ID;

I used the fieldname TorF for you True or False field.

I hope this helps.
 

Users who are viewing this thread

Back
Top Bottom