Base: In basic, how do you open a form to a particular record number?

This is some example code I'm using that opens a form. How do set set
the current record number of the newly opened form from the basic
script.

Sub OpenDataEntry(oEvent As Object)
    Dim FrmName as string
    FrmName = "Finalization - Data Entry"
    ThisDatabaseDocument.FormDocuments.getByName(FrmName).open()
End Sub

I'm a programmer. Does anyone know where a useable API reference is
for libreoffice basic? I have looked at the "documentation" and there
is no apparent reference to ThisDatabaseDocument , FormDocuments ,
getByName , and etc. Surely there is a real API reference or some
trick I'm missing out there

Thanks
Jason White

Jason ,

on the website from Roberto Benitez <http://www.baseprogramming.com/> you wil find what you are looking for !

As far as I can tell, this website only (and I mean only) has two blog
posts about Java programming. No references, nor anything else that
seems useful. Perhaps the website has changed owner recently?

Ok, so he put up a blog over his old site. I found the old content and
the is no reference to opening a form from a basic macro. Surely the
is an object reference. Aka Real documentation for Basic programming
out there somewhere ?

Hi :slight_smile:
Maybe one of the links in this link?
https://wiki.documentfoundation.org/Documentation/Other_Documentation_and_Resources#Programmers

It would be nice if the link that has already been given could be added in there so feel free if you know how to edit a wiki (it easy to learn by just doing it)
Regards from
Tom :slight_smile:

https://wiki.documentfoundation.org/images/5/50/BH40-BaseHandbook.odt
http://www.baseprogramming.com/OOBasicDatabaseDev.pdf

http://www.pitonyak.org/database/
http://www.pitonyak.org/database/AndrewBase.odt
http://www.pitonyak.org/oo.php

These links just provide some ideas of other places to look

http://wiki.openoffice.org/wiki/Documentation/DevGuide/Database/Using_DBMS_Features

http://www.openoffice.org/api/docs/common/ref/com/sun/star/sdbc/TransactionIsolation.html

Well, thank you everyone for all the references. I've figured out the
I am doing things backwards, I have the tool Xray, and the 1500 page
introductory developers guide. Clearly this is a question for one of
the core developers (if its not documented in the developers guide)

Hi :slight_smile:
Yes, sorry for all the Rtfm answers!  Prolly is best to ask on devs lists as they might have more idea of what you are doing.  There are a few here that seemed to understand but it was all waaay beyond me. 
Regards from
Tom :slight_smile:

Hi Jason,

This is some example code I'm using that opens a form. How do set set
the current record number of the newly opened form from the basic
script.

Sub OpenDataEntry(oEvent As Object)
    Dim FrmName as string
    FrmName = "Finalization - Data Entry"
    ThisDatabaseDocument.FormDocuments.getByName(FrmName).open()
End Sub

I'm a programmer. Does anyone know where a useable API reference is
for libreoffice basic? I have looked at the "documentation" and there

Try here :
http://api.libreoffice.org/docs/common/ref/com/sun/star/module-ix.html

http://api.libreoffice.org/docs/common/ref/com/sun/star/sdbcx/ResultSet.html

http://api.libreoffice.org/docs/common/ref/com/sun/star/sdbcx/XRowLocate.html

You might need to get/set the cursor or a "bookmark" for the
resultset/rowset.

Alex

Hi Jason,

You might be able to adapt this Sub for your needs: -

Sub FindRecord(iTargetID AS Integer)
    Dim oColumn AS Object
    Dim iColumnValue AS Integer
    Dim iRow AS Integer
    Dim rs AS Object
    Dim sTargetID AS String

     rs = goFormTransHeader.createResultSet()
     if rs.absolute(iTargetID) = false then ' Check if rs is past end of
Table
         rs.Previous()
      End if

     Do
         oColumn = rs.Columns.getByName("TransHeaderID")
        iColumnValue = rs.getInt(1)
        iRow = rs.Row
        if iColumnValue = iTargetID then
            goFormTransHeader.absolute(iRow)
            Exit Sub
        else
            if iColumnValue < iTargetID then
                sTargetID = iTargetID
                MsgBox("Record " + sTargetID + " not found",0,"ERROR")
                Exit Sub
            End if
        End if
    Loop While rs.Previous()
End Sub

Notes:-
1. TargetID is the key value for the record I want to display on the Form
2. goFormTransHeader is my global variable for the Form
3. TransHeaderID is the key field of my Table. (Integer, auto increment)
4. I have relatively few deletions from the Table so TransHeaderID is
fairly
     close to the required row number. Thus a number of rs.Previous()
cycles
     is usually all I need. In your case if that is too slow, you might
need to
     consider doing a binary search.

Let me know if you have any questions.

Noel

Hi,

When I have a database open in form view, there is a block where I can select a specific record number in the bottom left of the screen

Don

Jason ,

this links opens a pdf <http://www.baseprogramming.com/OOBasicDatabaseDev.pdf>