Connecting Tech Pros Worldwide Help | Site Map

Display the last records in a table on a continuous form

  #1  
Old November 18th, 2008, 11:55 PM
Greg (codepug@gmail.com)
Guest
 
Posts: 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
  #2  
Old November 19th, 2008, 04:55 AM
Tom van Stiphout
Guest
 
Posts: n/a

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
  #3  
Old November 19th, 2008, 04:45 PM
Greg (codepug@gmail.com)
Guest
 
Posts: n/a

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


  #4  
Old November 19th, 2008, 04:55 PM
Greg (codepug@gmail.com)
Guest
 
Posts: n/a

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
  #5  
Old November 19th, 2008, 05:05 PM
Greg (codepug@gmail.com)
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
bookmark continuous form slow slow slow eighthman11 answers 13 November 28th, 2007 12:05 AM
Editable query / continuous form with aggregate fields: how? S P Arif Sahari Wibowo answers 3 January 18th, 2006 06:05 PM
DSum([Field) in Subform where its current-records are stored with all subform records phaddock4@sbcglobal.net answers 1 November 13th, 2005 07:34 AM
How to show the contents of a field (50 items) in a form not in vertical way but 5 rows 10 columns? Paul T. Rong answers 15 November 13th, 2005 04:39 AM