Query Cretira

amfroehlich

Board Regular
Joined
Jul 14, 2004
Messages
192
I have a query pulling one speific record. I want it to pull the last one saved to the database. Can i do this?
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
My suggestion would be to add a general timestamp to the table, that is updated to Now() everytime a change is made. You can then setup a query to with this datestamp sorted decending, and setup the query properties to return the TOP=1 records. This should return your most recent save.


PS- If 2 records were changed in the same second you might get the wrong one. If it's a single user entry database, this shouldn't be a problem. Multiuser could have this happen.

HTH
Cal
 
Upvote 0
Following on from Cal's suggestion, if you already have a variable that increases in value when a new record is added to the table (e.g. an autonumber or a numeric identifer), then you could select the newest item with a query (view totals) with the total part set to "Max" for that autonumber variable. Such a query would return one record being the last record in the table.

HTH, Andrew. :)
 
Upvote 0
andrew,
I was thinking along the same lines at first. The only problem is that the OP didn't specify if the last saved record could be a modified record, as opposed to a new record. If modified with an autocount, the autocount would remain the same, if modified with a date/time stamp, the value would need to be updated at the modified time. Hense my using a date/time stamp.

Cal
 
Upvote 0
Hi Cal, a good point (that I hadn't thought of) - I had interpreted "last record saved" as being the last record created.
:oops:
My misatke (spelling intended)
:biggrin:
 
Upvote 0

Forum statistics

Threads
1,221,825
Messages
6,162,166
Members
451,750
Latest member
dofrancis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top