Retrieve last row Value from Access Table

Siyanna

Well-known Member
Joined
Nov 7, 2011
Messages
1,146
Hi All

I have a table called Log which gets updated when something gets updated

What i want to be able from the Column called Version - i want to retrieve the last row value in that column

say it says V8

i want to on workbook open check to see if the value matches the cell value on sheet2!A1 - if it does then fine but if it doesnt then close the workbook saying not in latest version

hoping you can help me
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
The order of records really has no meaning in Access tables (someone once described it as a bag of jumbled marbles).
You can do an Aggregate Query, to return a record with the oldest/newest date or maximum/minimum value.
So, is there some field you can use to determine exactly which record you want to return? Maybe some sort of date field?
 
Upvote 0
Thank you for that explanation

i didnt have a value to sum but i managed to get the value by ordering it by version number and then selected top 1 from that column
 
Upvote 0
maybe if it has a date column and you know a little vba then do a select query order by date and do a recordset.movelast
 
Upvote 0
i didnt have a value to sum but i managed to get the value by ordering it by version number and then selected top 1 from that column
Aggregate Queries are used for more than just summing! ;)

I was thinking you could use First/Last or Min/Max on some field.
See: https://support.office.com/en-us/ar...unctions-a810ee71-c1cd-43d7-9c55-8005f1893be5

i didnt have a value to sum but i managed to get the value by ordering it by version number and then selected top 1 from that column
The query might look something like this:
Code:
SELECT *
FROM MyTable
WHERE Version_Number = 
(SELECT Max(MyTable.Version_Number)
FROM MyTable);

maybe if it has a date column and you know a little vba then do a select query order by date and do a recordset.movelast
You *could* do it this way, but VBA/Recordsets seems to be a bit overkill and unnecessary here. You would still need to Sort/Order the records first, and if you can do that, you can simply use that field in an Aggregate Query instead.
 
Last edited:
Upvote 0
If you have an autonumber or date field then you could also combine Dmax with Dlookup to get the true last. If there is no additions or deletions then DLast will get the last entry.
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,429
Members
448,961
Latest member
nzskater

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