Using SelTop on a continuous form (1 Viewer)

Tim Bedborough

Registered User.
Local time
Today, 16:34
Joined
Nov 16, 2015
Messages
42
Hi all

I have a main form and a sub form. The sub form is continuous. I want to add a button in the main form that sets focus on the sub form, goes to the last record in the sub form but shows the last 'x' number of records (can get about 20 in the main form space allocated to the sub form.

The following code unlocks the main form and sub forms (there are 2), then sets the focus on the sub form (subfrmActivityDateOrder) and goes to the last record OK BUT only shows the last record rather than using up the space to show more than 1 continuous record.

Private Sub btnLast_Click()

Me.AllowEdits = True
Me.AllowDeletions = True
Me.AllowAdditions = False

Me.subfrmActivityDateOrder.Enabled = True
Me.subfrmVariationsDateOrder.Enabled = True
Me.subfrmActivityDateOrder.SetFocus

DoCmd.RunCommand acCmdRecordsGoToLast

End Sub

I tried adding me.seltop = me.seltop - 20 but it seemed to identify the main form rather than the sub form.

I tried using the full path name for the sub form (Forms.frmjobs.subfrmActivityDateOrder.) but this created an error.

I can stick with what I have but feels a bit 'unfinished' !

Any thoughts or ideas appreciated please.

Thanks in advance.
 

MarkK

bit cruncher
Local time
Today, 09:34
Joined
Mar 17, 2004
Messages
8,181
You can use the .Recordset property of the subform. Put this routine on the subform, call it from the Main form...
Code:
Public Sub ShowLast(x as integer)
   dim i as integer
   With Me.Recordset
      .MoveLast
      .Move -x
      .MoveLast
   End With
End SUb
But you might have to check for .BOF somewhere in case your x values is > than the number of records in the form.
 

Tim Bedborough

Registered User.
Local time
Today, 16:34
Joined
Nov 16, 2015
Messages
42
Hi Mark
Thanks for feedback. Not sure this does the job partly because I don't understand the .BOF reference. If you can throw any more light on it or have any other ideas would be good. Thanks anyway.
 

Users who are viewing this thread

Top Bottom