By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,374 Members | 2,993 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,374 IT Pros & Developers. It's quick & easy.

Display the last records in a table on a continuous form

P: n/a
I want to display the last 22 records in my continuous form. I have
writen the following
code and it works, but was wondering if there were any better
suggestions for accomplishing
this. My code scrolls the screen as it goes to bottom and than scrolls
out the 22 recs.

My code:

Private Sub GoToBottom()
Dim X As Integer
X = 0
If Not ([Form].RecordsetClone.EOF) Then
DoCmd.GoToRecord , , acLast
If [Form].RecordsetClone.RecordCount 22 Then
For X = 1 To 22
DoCmd.GoToRecord , , acPrevious
Next
End If
End If
End Sub
Nov 18 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Tue, 18 Nov 2008 15:53:53 -0800 (PST), "Greg (co*****@gmail.com)"
<co*****@gmail.comwrote:

You can try this:
Private Sub GoToBottom()
Dim X As Integer
with [Form].RecordsetClone
If Not .EOF Then
'Update RecordCount
.MoveFirst
.MoveLast
If .RecordCount 22 Then
.Move -22
[Form].Bookmark = .Bookmark
End If
End If
End Sub

>I want to display the last 22 records in my continuous form. I have
writen the following
code and it works, but was wondering if there were any better
suggestions for accomplishing
this. My code scrolls the screen as it goes to bottom and than scrolls
out the 22 recs.

My code:

Private Sub GoToBottom()
Dim X As Integer
X = 0
If Not ([Form].RecordsetClone.EOF) Then
DoCmd.GoToRecord , , acLast
If [Form].RecordsetClone.RecordCount 22 Then
For X = 1 To 22
DoCmd.GoToRecord , , acPrevious
Next
End If
End If
End Sub
Nov 19 '08 #2

P: n/a
Thanks Tom

Your suggestion worked great! And smooooth response at the screen.

Greg
Nov 19 '08 #3

P: n/a
oops!

Just one little problem. For some reason, when I call this code in the
OnOpen event of the form
it does not always work. It seems that the code gets run before the
data is displayed, so becomes ignored.
This happens when the database is started for the first time, however,
if the form is switched from design mode
and then to view mode it works. Strange. The code that I originally
submitted, works in both scenerios, but
I don't like it because it causes a brief screen scroll. Any ideas why
the new suggested code is not executing when
the database first starts up ?

Greg
Nov 19 '08 #4

P: n/a
'I included the following DoCmd statement in the OnOpen event only,
and this worked.

DoCmd.GoToRecord , , acLast
Call GoToBottom
Thanks Greg
Nov 19 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.