[Solved] Open a second form with a set filter from parent

Creating and using forms
Post Reply
User avatar
NiksaVel
Posts: 91
Joined: Fri Jan 25, 2008 12:00 pm
Location: Croatia

[Solved] Open a second form with a set filter from parent

Post by NiksaVel »

Hi all,

I need to do a bit complex stuff with several forms used for both viewing and entering data... what I need is like this:

I have a main form with a list of patients and a number of buttons all leading to different forms all partaining to various examinations...

there is a patients table and a separate table for every different exam...


What I want is to be able to select a patient in the first form that is listed in table form and click a button...

the button opens the second form that has the main form listing all exams performed for that specific exam that was clicked, but with a filter to show only exams done on the preselected patient...


I have very little knowledge about macros/sql... most of my stuff is done with help from here and the macros I find online... I don't have enough knowledge to write them myself, so I'm asking here for help :)


thanks in advance!
Last edited by NiksaVel on Wed May 14, 2008 12:21 am, edited 1 time in total.
OOo 3.1.X on Ubuntu 8.x + Linux Mint 7, Win XP, Vista
User avatar
NiksaVel
Posts: 91
Joined: Fri Jan 25, 2008 12:00 pm
Location: Croatia

Re: Open a second form with a set filter from the parent form

Post by NiksaVel »

some1 please help :(
OOo 3.1.X on Ubuntu 8.x + Linux Mint 7, Win XP, Vista
User avatar
NiksaVel
Posts: 91
Joined: Fri Jan 25, 2008 12:00 pm
Location: Croatia

Re: Open a second form with a set filter from the parent form

Post by NiksaVel »

Found the answer here if anyone was wondering :)
http://www.oooforum.org/forum/viewtopic ... 702#164702

Code: Select all

REM  *****  BASIC  *****
GLOBAL myindex as integer

sub Main
'Get the form (in this case TestForm1 = records of the database).
   odoc=thiscomponent
   oform=odoc.drawpage.forms.getbyindex(0)
   
'Get the contents of the first row (=index field in my case) of the selected record.
   myindex=oform.getstring(1)
 
'Display the second form (TestForm2).
   OpenForm(getFormsTC, getConnectionTC,"TestForm2")

'Filter the TestForm2.
   odoc=thiscomponent
   oform=odoc.drawpage.forms.getbyindex(0)
   oform.ApplyFilter = True
   
   oform.filter =("TestID = " & myindex)
 
'Reload the TestForm2 with the filter applied.
   oform.reload
End Sub

function OpenForm( formContainer as variant, oConnection as variant, sFormName as string) as variant
   Dim aProp(1) As New com.sun.star.beans.PropertyValue
   aProp(0).Name = "ActiveConnection"
   aProp(0).Value = oConnection
   aProp(1).Name = "OpenMode"
   aProp(1).Value = "open"
   OpenForm = formContainer.loadComponentFromURL(sFormName,"_blank",0,aProp())
end function

function getFormsTC() as variant
   getFormsTC = thisComponent.Parent.getFormDocuments
end function

function getConnectionTC() as variant
   getConnectionTC = thisComponent.Drawpage.Forms(0).ActiveConnection
end function 
OOo 3.1.X on Ubuntu 8.x + Linux Mint 7, Win XP, Vista
Post Reply