OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

how to open a form displaying a specific record? (solved)

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
balu_vom_muh
General User
General User


Joined: 28 Nov 2008
Posts: 11

PostPosted: Mon Jul 06, 2009 9:49 pm    Post subject: how to open a form displaying a specific record? (solved) Reply with quote

If I open a form, it displays by default the first record of the connected table. How can I get the form to display a specified record? I'm searching a solution for subforms which should display the record specified in the main-form.

Last edited by balu_vom_muh on Thu Feb 16, 2012 8:08 am; edited 1 time in total
Back to top
View user's profile Send private message
QuazzieEvil
Super User
Super User


Joined: 17 Jan 2007
Posts: 599
Location: Houston, TX

PostPosted: Tue Jul 07, 2009 5:02 am    Post subject: Reply with quote

Bind a macro to the When Loading event of the form, then use any of the form's navigation methods: first(),last(),next(),absolute(..)

Code:

Sub Form_WhenLoading(Event As Object)
   Dim Form As Object
   
   Form=Event.Source
   'Form.absolute(5) 'move to fifth row
   Form.last() 'move to last rec
   'Form.first() 'move to first rec
End Sub

_________________
Free Docs @ http://www.baseprogramming.com/resources.html
Book @ lulu.com http://www.lulu.com/content/2455551
Back to top
View user's profile Send private message Visit poster's website
balu_vom_muh
General User
General User


Joined: 28 Nov 2008
Posts: 11

PostPosted: Sun Jul 12, 2009 8:02 am    Post subject: Reply with quote

I added "Form.last()" to my code, but the original form, not the depend one, moves to the last record. How can I focus the code to the second form?
Note: I create forms with text-documents (not with the form-generator of oobase) and link them to the database.


Sub BriefZuDatensatzOeffnen(Event as Object)

Dim Form as Object
Dim Bookmark as variant
Dim oDoc as object
Dim Url As String
dim myFileProp(0) as new com.sun.star.beans.PropertyValue

Form = Event.Source.Model.Parent
TextBox = Form.getByName( "NAMEVORNAME" )
NAMEVORNAME = TextBox.CurrentValue
Datei = "Praxis/Dokumente.odt"
myFileProp(0).name="ReadOnly"
myFileProp(0).value=True
oDoc = StarDesktop.loadComponentFromURL(FormVorlageLaden, "Rahmen", SearchFlags, myFileProp())
Form.last()

end sub
Back to top
View user's profile Send private message
crixtiano
General User
General User


Joined: 15 Jun 2010
Posts: 7

PostPosted: Tue Jun 26, 2012 11:36 am    Post subject: Reply with quote

And how to open "where id=5", for example?
_________________
Cristiano Meira Magalhaes
Back to top
View user's profile Send private message
ubuntuuser
General User
General User


Joined: 26 Jun 2012
Posts: 8

PostPosted: Tue Jun 26, 2012 2:39 pm    Post subject: Reply with quote

the same thing but you use another function of XResultSet
http://www.openoffice.org/api/docs/common/ref/com/sun/star/sdbc/XResultSet.html

Code:

Dim oForm as object
oForm = ThisComponent.DrawPage.Forms.getbyindex(0)
oForm.Absolute(5)


5 is the number of the row not an index.
If you want to jump to a row with a specific id or a specific value in the query, as far as i know it would be more difficult: you should loop until you find your value and then use Absolute
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group