473,387 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Display the last records in a table on a continuous form

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
4 4855
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
Thanks Tom

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

Greg
Nov 19 '08 #3
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
'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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: David | last post by:
Hi, I have an order form which has a field 'ProductID'. This form has a button on each record to open a new form linked by ProductID. This new form is a continuous form and obviously, only...
1
by: huela | last post by:
Somehow i have to display the recordset in unbound form When i use the following display the data in recordset to unbound form. I have a question: i can only display the last record data, all...
3
by: Richard Hollenbeck | last post by:
I have the following query in my form's code: Private Function Get_Data(fieldNum As Integer) Dim strSQL As String Dim db As DAO.Database Dim rs As DAO.Recordset strSQL = "SELECT & "", "" & ...
4
by: vidiot | last post by:
I am trying to create a subform that will display images related to the parent form. The subform is a continuous form as there will be several images that relate to the parent form. I checked...
3
by: ApexData | last post by:
I am using a continuous form for display purposes. Above this form, a single record is displayed so that when the user presses my NewButton they can enter a NewRecord which gets added to the...
0
by: Andrew | last post by:
Hi all A quick question which I've not been able to solve from trawling the web. Is it possible to have a control in the detail section of a form set to a default view of "Continuous" which...
3
by: Clint Stowers | last post by:
Access 2003 I have a Continuous Form. On Open I force it to go to the Last Record. When the form opens only the last record is shown at the top. To view any of the previous records you must...
3
by: Ian | last post by:
I have a form with a sub form, on the continues sub for I want to display some data along with a picture, on the On Current event I have the code: .Picture = Nz() is the name of the picture...
46
by: OldBirdman | last post by:
What a mess this question is. I have spent 2 weeks trying to make it concise and clear, and I can't. I do not have the vocabulary for the question. I cannot even TITLE it correctly. Here is my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.