(help macro base)Open form with a button form another form with filter

my macro dont apply filter why?

GLOBAL myindex as integer

sub pega( oev as variant )
dim odoc,oform,sfilter
odoc=thiscomponent
oform=odoc.drawpage.forms.getbyindex(0)
  'pega o dado da primeira linha(=index =campo Cad no meu caso) do registro
atual
         myindex=oform.getstring(1)

ThisDatabaseDocument.FormDocuments.getByName( "animal3" ).open

  odoc=thiscomponent
     oform=odoc.drawpage.forms.getbyindex(0)

  'define o filtro para achar os registros

         sfilter = chr(34) & "Cad" & chr(34) & chr(61) & myindex
         print sfilter
         oform.filter = sfilter
         oform.applyfilter= True
         oform.reload ' recarrega o formulario com o filtro pelo na
teoria pois não esta funcionando
                                  'reload the form with the filter apply
dont work

end sub

Hi Rogerio,

ThisDatabaseDocument.FormDocuments.getByName( "animal3" ).open

  odoc=thiscomponent
     oform=odoc.drawpage.forms.getbyindex(0)

  'define o filtro para achar os registros

         sfilter = chr(34) & "Cad" & chr(34) & chr(61) & myindex
         print sfilter
         oform.filter = sfilter
         oform.applyfilter= True
         oform.reload ' recarrega o formulario com o filtro pelo na
teoria pois não esta funcionando
                                  'reload the form with the filter apply
dont work

I could be wrong here, but you could try setting the focus on one of
this form's controls before attempting to reload, or alternatively you
might find you have to reload the first form that was opened in order to
get the second one to update. From memory, I think that there was a
discussion about this on the old OpenOffice.org dba discuss or user list.

Alex

Hi

Sorry if this is a silly question but, how do I switch the focus from one
form to another?

Thanks

Hi Rogerio,

Sorry if this is a silly question but, how do I switch the focus from one
form to another?

I actually looked this up on the OpenOffice.org forum, but I can't find
the link to the post anymore. There might also be a bug in LibreOffice
that prevents the form from reloading. I seem to recall having seen
something similar somewhere, because the filter.appply = true and
form.reload used to work with OpenOffice.org.

Alex

Alex ,
thank you.
I will return to the problem when version 3.4.2 is launched (in july)

well now

with 3.4.2
ubuntu11.04 64bits
and use hsql

now I have error mensage in filter Why?

the basetools extension (0.0.5) works in libreoffice 3.4.2 ?

Yes, now is works, but i can't insert new record in filter form.

sub pega( oev as variant)
Dim Filter As String
dim odoc,odoc2,oform2,oform as Object
odoc=thiscomponent
  oform=odoc.drawpage.forms.
getbyindex(0)

  'pega o dado da primeira linha(=index =campo Cad no meu caso) do registro
atual
  myindex=oform.getstring(1)

'ThisDatabaseDocument.FormDocuments.getByName( "animal3" ).open
oform2=ThisDatabaseDocument.FormDocuments.getByName( "animal3" )
oform2.Open
oform2 = oform2.Component.DrawPage.Forms.getbyindex(0)

  'define o filtro para achar os registros

        oform2.filter ="animal3.Cad ='" & myindex &"'"
        oform2.ApplyFilter= True
        oform2.reload

End Sub

All this is perfectly doable even without a single line of silly Basic:
http://user.services.openoffice.org/en/forum/viewtopic.php?f=83&t=40493

Ok , But I need to fix myindex value in new record.

      animal3.cad = myindex not automatic in new record

ok I have the answer here
http://www.oooforum.org/forum/viewtopic.phtml?t=28839