Connecting Tech Pros Worldwide Forums | Help | Site Map

Display the last records in a table on a continuous form

Greg (codepug@gmail.com)
Guest
 
Posts: n/a
#1: Nov 18 '08
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

Tom van Stiphout
Guest
 
Posts: n/a
#2: Nov 19 '08

re: Display the last records in a table on a continuous form


On Tue, 18 Nov 2008 15:53:53 -0800 (PST), "Greg (codepug@gmail.com)"
<codepug@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

Quote:
>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
Greg (codepug@gmail.com)
Guest
 
Posts: n/a
#3: Nov 19 '08

re: Display the last records in a table on a continuous form


Thanks Tom

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

Greg


Greg (codepug@gmail.com)
Guest
 
Posts: n/a
#4: Nov 19 '08

re: Display the last records in a table on a continuous form


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
Greg (codepug@gmail.com)
Guest
 
Posts: n/a
#5: Nov 19 '08

re: Display the last records in a table on a continuous form


'I included the following DoCmd statement in the OnOpen event only,
and this worked.

DoCmd.GoToRecord , , acLast
Call GoToBottom


Thanks Greg
Closed Thread