Ask Your Question
0

How do I let Base jump to the last record of a table in a form?

asked 2019-08-08 18:08:25 +0200

geogre gravatar image

Hello,

I am using a database form displaying a table to enter data. When I open that form it takes a second until it's opened and then the first record is selected (the oldest entry).

I would absolutely love it to jump automatically to the LAST line (the newest record) instead!

The way it is now, I always have to click the "jump to last entry" icon...

Thank you for any help!

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2019-08-15 15:43:41 +0200

EasyTrieve gravatar image

updated 2019-08-16 15:32:18 +0200

If you just want to move to the last record, without moving to the insert record (the one after the last record), then hook this to Form's When Loading event:

Option Explicit

Private Sub WhenLoadingNew(oEvent As Object)
   REM Clone allows record motion independent of record updating

   Dim oForm      As Object :oForm      = oEvent.Source
   Dim oDoc       As Object :oDoc       = ThisComponent
   oDoc.lockControllers
       oForm.moveToInsertRow  ' Pushes windows down to allow this to easily show later'
       oForm.Last
   oDoc.unlockControllers
End Sub
edit flag offensive delete link more

Comments

@EasyTrieve,

Tried replacing my routine with yours. I get nothing. Just opens on first record.

Ratslinger gravatar imageRatslinger ( 2019-08-15 20:13:20 +0200 )edit

@Ratslinger, Sorry, I forgot to extract the 2'nd half w/ the moveToInsertRow, then Last. Now it should work.

EasyTrieve gravatar imageEasyTrieve ( 2019-08-16 07:03:40 +0200 )edit

Yeah, it works now. More lines of code but doesn't need to set fetch size.

Just a note - only need Last or moveToInsertRow. Not both, only one or the other.

Ratslinger gravatar imageRatslinger ( 2019-08-16 07:46:07 +0200 )edit

@Ratslinger, also chopped out the clone line and it still works. Then added comment for the reason moveToInsertRow is needed. (For data sets larger than one page.)

EasyTrieve gravatar imageEasyTrieve ( 2019-08-16 15:33:37 +0200 )edit

Interesting, if you leave in this line:

Dim oRS_clone  As Object :oRS_clone  = oForm.createResultSet() : oRS_clone.Last()

you don't need both Last and moveToInsertRow. Remove the line and you need both.

Ratslinger gravatar imageRatslinger ( 2019-08-16 18:18:56 +0200 )edit
0

answered 2019-08-15 03:59:53 +0200

Ratslinger gravatar image

updated 2019-08-15 07:14:18 +0200

Hello,

If you always want to enter new records only, this is a property of the form.

If you also want existing records displayed, you need to use a macro:

Sub SetFetch
    oForm2 = ThisComponent.Drawpage.Forms.getByName("YOUR_INTERNAL_FORM_NAME")
  REM set this to something higher than existing # of records
    oForm2.FetchSize = 5000
    oForm2.Reload()
    oForm2.last
End Sub

Set the Open Document event of the form to this macro.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-08-08 18:08:25 +0200

Seen: 47 times

Last updated: Aug 16