Query to return last record

  • Thread starter Thread starter gavin
  • Start date Start date
G

gavin

Is it possible to have a query which will return the most recently entered
record in a table - in other words the record with the biggest ID number?


Thanks,


Gavin
 
Is it possible to have a query which will return the most recently entered
record in a table - in other words the record with the biggest ID number?


Thanks,


Gavin
Gavin,
If in fact the biggest ID is the most recently entered record, then

SELECT tblBasicData.*
FROM tblBasicData
WHERE (((tblBasicData.ID)=DMax("[ID]","tblBasicData")));
 
Gavin
Please, please please tell me if this works for you.

-----Original Message-----
Is it possible to have a query which will return the most recently entered
record in a table - in other words the record with the biggest ID number?


Thanks,


Gavin
Gavin,
If in fact the biggest ID is the most recently entered record, then

SELECT tblBasicData.*
FROM tblBasicData
WHERE (((tblBasicData.ID)=DMax("[ID]","tblBasicData")));



--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
.
 
How do you do this?
Is it possible to have a query which will return the most recently entered
record in a table - in other words the record with the biggest ID number?


Thanks,


Gavin
Gavin,
If in fact the biggest ID is the most recently entered record, then

SELECT tblBasicData.*
FROM tblBasicData
WHERE (((tblBasicData.ID)=DMax("[ID]","tblBasicData")));



--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
.
.
 
How do you do this?
Is it possible to have a query which will return the most recently entered
record in a table - in other words the record with the biggest ID number?


Thanks,


Gavin


Gavin,
If in fact the biggest ID is the most recently entered record, then

SELECT tblBasicData.*
FROM tblBasicData
WHERE (((tblBasicData.ID)=DMax("[ID]","tblBasicData")));



--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
.

Peggy,
Do what?
What part of this do you need help on?
 
That query works great - thanks Fred!

Can I just ask if a small modification is possible? If I run this query it
opens in datasheet view. I have a data entry form already set up - can this
query be made to display its result (one record) in this form?



Gavin




Is it possible to have a query which will return the most recently entered
record in a table - in other words the record with the biggest ID number?


Thanks,


Gavin
Gavin,
If in fact the biggest ID is the most recently entered record, then

SELECT tblBasicData.*
FROM tblBasicData
WHERE (((tblBasicData.ID)=DMax("[ID]","tblBasicData")));



--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
 
Sure.
Make the query the record source for the form.

Open the form.
The form will display the data for that record
(or as many records match the criteria).

That query works great - thanks Fred!

Can I just ask if a small modification is possible? If I run this query it
opens in datasheet view. I have a data entry form already set up - can this
query be made to display its result (one record) in this form?



Gavin




Is it possible to have a query which will return the most recently entered
record in a table - in other words the record with the biggest ID number?


Thanks,


Gavin
Gavin,
If in fact the biggest ID is the most recently entered record, then

SELECT tblBasicData.*
FROM tblBasicData
WHERE (((tblBasicData.ID)=DMax("[ID]","tblBasicData")));



--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
 
Brilliant - I love it! Many thanks, Fred.


Gavin



Sure.
Make the query the record source for the form.

Open the form.
The form will display the data for that record
(or as many records match the criteria).

That query works great - thanks Fred!

Can I just ask if a small modification is possible? If I run this query it
opens in datasheet view. I have a data entry form already set up - can this
query be made to display its result (one record) in this form?



Gavin




Is it possible to have a query which will return the most recently entered
record in a table - in other words the record with the biggest ID number?


Thanks,


Gavin


Gavin,
If in fact the biggest ID is the most recently entered record, then

SELECT tblBasicData.*
FROM tblBasicData
WHERE (((tblBasicData.ID)=DMax("[ID]","tblBasicData")));



--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
 
Did you get it working, Peggy - it worked great for me.



Gavin



Peggy said:
How do you do this?
Is it possible to have a query which will return the most recently entered
record in a table - in other words the record with the biggest ID number?


Thanks,


Gavin


Gavin,
If in fact the biggest ID is the most recently entered record, then

SELECT tblBasicData.*
FROM tblBasicData
WHERE (((tblBasicData.ID)=DMax("[ID]","tblBasicData")));



--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
.
.
 
Ok, I'm in need of a little help... I know this is a simple task, but I
need a push since my brain isn't working... I have a database that
allows officers to give tickets to violators... I'm trying to create a
query that joins the violators table (violatorID (primary key), and
OperatorLicenseNumber) and the violations table (violatorID(foreign
key), DateTimeViolation)... I want to be able to return the last record
of a datetimeviolation, and the operatorlicensenumber of that last
violation. How would I go about putting it into code? So far, I've
got:

SELECT a.ViolatorID, OperatorLicenseNumber, DateTimeViolation
FROM Violators AS a INNER JOIN Violations AS b
ON a.ViolatorID = b.ViolatorID

but how do I pull up the last datetimeviolation, along with showing the
violators operatorlicensenumber?


Ugh... I love SQL, but help!
 
Back
Top