Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


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
--
Noel Lodge
lodgemn@gmail.com


On 7 August 2013 05:57, Tom Davies <tomdavies04@yahoo.co.uk> wrote:

Hi :)
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 :)





________________________________
From: Jason White <whitewaterssoftwareinfo@gmail.com>
To: andrew@pitonyak.org
Cc: users@global.libreoffice.org
Sent: Tuesday, 6 August 2013, 16:43
Subject: Re: [libreoffice-users] Base: In basic, how do you open a form
to a particular record number?


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)

On Tue, Aug 6, 2013 at 11:21 AM, Andrew Douglas Pitonyak
<andrew@pitonyak.org> wrote:

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

On 08/06/2013 09:23 AM, Jason White wrote:

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


--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
Info:  http://www.pitonyak.org/oo.php



--
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems?
http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more:
http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be
deleted




--
Jason White

--
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems?
http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be
deleted



--
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems?
http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be
deleted



-- 
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.