filter out last record

icemonster

Registered User.
Local time
Today, 09:59
Joined
Jan 30, 2010
Messages
502
hello,

how do i filter out my query to show only the last record entered? thanks.
 
If you have a autonumber field you could filter the highest value or if you have a field with date/time you could use that.
 
If you have a autonumber field you could filter the highest value or if you have a field with date/time you could use that.

Sorry to disagree with your autonumber assessment, but I have to. An Autonumber is NOT guaranteed to give you incrementing numbers and can, depending on the circumstances give you negative numbers even when you have it set to increment instead of random.

So the date/time stamp is the most efficient and safest way to ensure you have the most recently added record.
 
No problem Bob - I'm the novice sticky out my neck here :)
 
No problem Bob - I'm the novice sticky out my neck here :)

I've been trying to just let things go if they aren't important. This one would be potentially important, so I thought I'd better mention it. We've had people on who have had their autonumbers suddenly go off of the incremental path and that can cause headaches if you are expecting it to run incrementally. If you don't care then it isn't a problem if it does go "rogue" on you. :)
 
cool so date and time then. so how do i filter it? when i use DMax, doesnt seem to work. what function would be best?
 
Or you can have a query that sorts by descending and selects the TOP 1.
 
ok, i am aplogizing in advance.

but should this work? DMax([date]) or DMax ([date],[tbl])
 
Something like this:
Code:
SELECT [I][COLOR=magenta]YourTableNameHere[/COLOR][/I].*
FROM [I][COLOR=magenta]YourTableNameHere[/COLOR][/I]
WHERE ((([COLOR=magenta][I]YourTableNameHere[/I][/COLOR].[Date])=(Select Max([Date]) From [I][COLOR=magenta]YourTableNameHere[/COLOR][/I])));
 
yeah but am getting a paramater value, and the value being asked is the table, cause i wrote it in a query first, i did so:

Current: DMax([DateRecorded],[tblRecords])
 
yeah but am getting a paramater value, and the value being asked is the table, cause i wrote it in a query first, i did so:

Current: DMax([DateRecorded],[tblRecords])

Did you bother to read my last post? The one with colors and all? It is nowhere near what you have here and what you have here won't work at all. So abandon that effort and move to what I showed you:
Code:
SELECT [I][COLOR=magenta]YourTableNameHere[/COLOR][/I].*
FROM [I][COLOR=magenta]YourTableNameHere[/COLOR][/I]
WHERE ((([COLOR=magenta][I]YourTableNameHere[/I][/COLOR].[Date])=(Select Max([Date]) From [I][COLOR=magenta]YourTableNameHere[/COLOR][/I])));
 

Users who are viewing this thread

Back
Top Bottom