472,958 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How to reach the last record in a subform ?

Good evening to all

Here is my problem :

I have a form with a subform. They are linked.

When I open the form I would like the subform to reach its last
record.

I tried the method docmd.gotorecord aclast but i did not
succeed.

Thank you for your help.

--
_________________________________

Site photo personnel :

http://perso.wanadoo.fr/photodim
Nov 12 '05 #1
10 17385
On Sat, 30 Aug 2003 19:03:50 +0200, "Alain Guichaoua" <_@wanadoo.fr>
wrote:

mysubformcontrol.form.recordsetclone.movelast

-Tom.

Good evening to all

Here is my problem :

I have a form with a subform. They are linked.

When I open the form I would like the subform to reach its last
record.

I tried the method docmd.gotorecord aclast but i did not
succeed.

Thank you for your help.


Nov 12 '05 #2
On Sat, 30 Aug 2003 10:20:34 -0700, Tom van Stiphout
<to*****@no.spam.cox.net> wrote:

Sorry, that previous post ran away from me. Here is the full code:
dim rs as dao.recordset
set rs = mysubformcontrol.form.recordsetclone
rs.movelast
mysubformcontrol.form.bookmark = rs.bookmark
set rs=nothing

-Tom.

On Sat, 30 Aug 2003 19:03:50 +0200, "Alain Guichaoua" <_@wanadoo.fr>
wrote:

mysubformcontrol.form.recordsetclone.movelast

-Tom.

Good evening to all

Here is my problem :

I have a form with a subform. They are linked.

When I open the form I would like the subform to reach its last
record.

I tried the method docmd.gotorecord aclast but i did not
succeed.

Thank you for your help.


Nov 12 '05 #3
On Sat, 30 Aug 2003 19:03:50 +0200 in comp.databases.ms-access, "Alain
Guichaoua" <_@wanadoo.fr> wrote:
Good evening to all

Here is my problem :

I have a form with a subform. They are linked.

When I open the form I would like the subform to reach its last
record.

I tried the method docmd.gotorecord aclast but i did not
succeed.


Just stick to putting one record in the subform - voilla :-)

In the main form:
Private Sub Form_Current()
Dim rs As Recordset
Set rs = MySubForm.Form.RecordsetClone
If rs.RecordCount Then
rs.MoveLast
MySubForm.Form.Bookmark = rs.Bookmark
End If
rs.Close
Set rs = Nothing
End Sub
--
A)bort, R)etry, I)nfluence with large hammer.

(replace sithlord with trevor for email)
Nov 12 '05 #4
> I have a form with a subform. They are linked.

When I open the form I would like the subform to reach its last
record.

I tried the method docmd.gotorecord aclast but i did not
succeed.


And yet another approach:

'************
Dim frm as Form
'Set reference to "subform"
Set frm = Me.MySubformControlName.Form

'Goto last record in subform
If frm.RecordsetClone.RecordCount > 0 Then
frm.SelTop = frm.RecordsetClone.RecordCount
End If
'************

--
Bruce M. Thompson, Microsoft Access MVP
bt******@mvps.org (See the Access FAQ at http://www.mvps.org/access)
NO Email Please. Keep all communications

within the newsgroups so that all might benefit.<<
Nov 12 '05 #5
Thank you Tom and Trevor, it works well.

Have a nice week-end

--
_________________________________

Site photo personnel :

http://perso.wanadoo.fr/photodim
Nov 12 '05 #6
Thank you to you too, Lyle; It is really nice to get many
solutions. I want to reach the last record (the one before a new
one) as in your exemple.

Bye !
--
_________________________________

Site photo personnel :

http://perso.wanadoo.fr/photodim
Nov 12 '05 #7
If the subform were showing ten records, would this show the last ten, with
the last one selected?


Yes.

--
Bruce M. Thompson, Microsoft Access MVP
bt******@mvps.org (See the Access FAQ at http://www.mvps.org/access)
NO Email Please. Keep all communications

within the newsgroups so that all might benefit.<<
Nov 12 '05 #8
"Bruce M. Thompson" <bthmpson@big_NOSPAM_foot.com> wrote in
news:vl************@corp.supernews.com:
Thank you to you too, Lyle; It is really nice to get many
solutions. I want to reach the last record (the one before a new
one) as in your exemple.


Uh ... as in my example, actually. <chuckle>


I'm very happy to confirm that it's Bruce's example.

<chuckle>

<chuckle>

--
Lyle

Nov 12 '05 #9
Comments interspersed.

"Lyle Fairfield" <ly******@yahoo.com> wrote in message
news:Xn******************************@130.133.1.4. ..
"Bruce M. Thompson" <bthmpson@big_NOSPAM_foot.com> wrote in
news:vl************@corp.supernews.com:
If the subform were showing ten records, would this show the last ten,
with the last one selected?
Yes.
More specifically, when the recordcount *is* 10 - and the last record is the
Current record.

Hmmmm ... I'll try my question again.

If frm.recordcount is >10
Okay, there is a slight difference from that which I reported in what will be
visible in the subform control because I used exactly 10 records.
and

frm shows 10 only records
.... frm *exposes* only 10 records (just to make sure we are on the same
wavelength).
and record 1 is selected
In the current event, which is where my example code was supposed to be entered,
there is a current record, not a selected record, but that may not be what you
are trying to say.
what happens when this code is run:

frm.SelTop = frm.RecordsetClone.RecordCount

?

Here in Canada only the last record is shown (and a "new" blank record if
appending is allowed).
Here in the US using Access 2000 on WinXP, when .Recordcount > 10, on Sunday,
the 31st of August, 2003, I see 9 records exposed (and a "new" blank record, if
appending is allowed). You may obtain different results. <g>
or am I missing something?
? <eg>
a kludge that could be used to display the last n records (where n =
number of records displayed in frm) and select the last is:

With Me
.SelTop = .RecordsetClone.RecordCount - _
(.InsideHeight - .FormHeader.Height - .FormFooter.Height) / _
.Detail.Height
.SelTop = .RecordsetClone.RecordCount
End With


Cool. Thanks, Lyle. :-)

--
Bruce M. Thompson, Microsoft Access MVP
bt******@mvps.org (See the Access FAQ at http://www.mvps.org/access) NO Email Please. Keep all communications

within the newsgroups so that all might benefit.<<
Nov 12 '05 #10
Trevor Best <bouncer@localhost> wrote in
news:s5********************************@4ax.com:
(Looks at Lyle now)
When you access that .RecordsetClone without explicity setting a
variable and closing and setting it to nothing afterwards, is the
reference to it still lingering around somewhere?


I believe referring to .recordsetclone creates not only another recordset,
but also another database, well, ... instance of the database. These two
objects die with the form; that is they do not have to be slaughtered by
helicopter gunships or murdered in the woods, for justification or revenge
or to be sure they don't do or say anything embarrassing to ourselves;
they're just like McArthur - they just fade away (but they don't smell as
bad).

Try this:

Private Sub Form_Load()
Dim z As Long
With Me
.SelTop = .RecordsetClone.RecordCount - _
(.InsideHeight - .FormHeader.Height - .FormFooter.Height) / _
.Detail.Height
.SelTop = .RecordsetClone.RecordCount
For z = 0 To DAO.DBEngine(0).Databases.Count - 1
MsgBox z & ": " & DAO.DBEngine(0)(z).Recordsets.Count
Next z
End With
End Sub

One gets two messages:

0: 0

and

1: 1

(assuming nothing else is happening in the db at the time.)

--
Lyle

Nov 12 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: sixsoccer | last post by:
I have built a database with a <Mainform> and a <Subform>. My problem is twofold. 1. My subform is set as a continuos form with AllowAddiotions set to NO (ie. a list of Issues to the client on...
17
by: michel.ank | last post by:
Hi, I'm using the class PrintLines and my last record of page aren't with the borders. Somebody can help me? Thanks,
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...
2
by: arthur.dayton | last post by:
I am using Access 2007. I'm trying to set the control on a subform to the current time. My code is: Private Sub Command7_Click() With Me. ..Form.SetFocus ..Form!.SetFocus RunCommand...
1
by: gavm360 | last post by:
Hello, I have a subform that has a command button to move to the next record. If there are more records i would just like to move to the next record, When the last record is reached I would like...
7
by: robtyketto | last post by:
Greetings, I have a main form. Upon filling in a combo box it then displays a subform (based on a query that uses values in the combo box on where clause) THe subform has the paramater Data...
3
by: Kan09 | last post by:
i'm having a problem with the requery and move to last command on some subforms. The subforms are used to view the data enterd into the table. I have 3 forms that use subforms. On 2 of the...
1
by: psyvanz | last post by:
here is the code im working with... hope you can understand? cause this thing searches the first one, not the last one record... i wanted ONLY to find the last record in a table... Please...
1
by: dekk | last post by:
Hi, Thanks for viewing this post. I have a subform called 'Time' that captures alot of time activity by day. Two of my fields are 'StartTime' and 'EndTime' I would like to increment the...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.