468,288 Members | 1,968 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,288 developers. It's quick & easy.

Finding the last record -10

I have a database with several tables, one of which is [Master Data
Table]

I use this to bring up a form so you can unlock the record (set by
using a yes no box on the data input form to prevent unauthorised
tweaking once the record is completed).

I would like to move to the last record but 10 to give the form 10
lines of the last entries, rather than one that is achieved by using
goto record.... acLast

I have tried using sql in the form open event such that I can obtain
the total number of records, take away 10 and then use the offset
parameter to move to the required records. But I cannot either get
the syntax rightusing it as a straight expression in the On Open event
of the record unlock form, as in:

Dim numofrecords as Long
numofrecords = (SELECT COUNT(*) FROM [Master Data Table])

or alternatively by using a subquery as an expression in the original
query that underlies the record unlock form. It is probably just a
syntax problem, but I cant find a good resource to give examples of
this usage. I can see using SQL being quite useful to filter and
obtain relevant data for forms requiring statistical inquiry, but am
jiggered if I know how at this time
Any help gratefully appreciated.

JBN
Nov 13 '05 #1
1 2093
On Mon, 14 Feb 2005 19:39:02 +0000, feck <ne*********@hotmail.com>
wrote:

Check out the Top predicate. Something like this may work (from the
Northwind sample app):
SELECT TOP 10 Orders.*
FROM Orders
ORDER BY Orders.OrderDate DESC;

Don't forget the Order By clause.

-Tom.

I have a database with several tables, one of which is [Master Data
Table]

I use this to bring up a form so you can unlock the record (set by
using a yes no box on the data input form to prevent unauthorised
tweaking once the record is completed).

I would like to move to the last record but 10 to give the form 10
lines of the last entries, rather than one that is achieved by using
goto record.... acLast

I have tried using sql in the form open event such that I can obtain
the total number of records, take away 10 and then use the offset
parameter to move to the required records. But I cannot either get
the syntax rightusing it as a straight expression in the On Open event
of the record unlock form, as in:

Dim numofrecords as Long
numofrecords = (SELECT COUNT(*) FROM [Master Data Table])

or alternatively by using a subquery as an expression in the original
query that underlies the record unlock form. It is probably just a
syntax problem, but I cant find a good resource to give examples of
this usage. I can see using SQL being quite useful to filter and
obtain relevant data for forms requiring statistical inquiry, but am
jiggered if I know how at this time
Any help gratefully appreciated.

JBN


Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Alistair | last post: by
2 posts views Thread by Devesh Aggarwal | last post: by
3 posts views Thread by JohnnyRuin | last post: by
10 posts views Thread by Alain Guichaoua | last post: by
6 posts views Thread by Maxi | last post: by
2 posts views Thread by Mark Vergara | last post: by
1 post views Thread by Presto | last post: by
reply views Thread by NPC403 | last post: by
2 posts views Thread by MrBee | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.