Page 1 of 1

Open form, filter on recordID

PostPosted: Sun Mar 04, 2018 9:09 pm
by ccj.gmr
Hi All,
I need help!
1- I can't open a form with a specific "record ID"!
2- How do I do a ".filter" with 3 variables/parameters? articleCode, supplierCode and referenID. Is this possible? The operador is &?
TY for your help.


Code: Select all   Expand viewCollapse view
Sub openDetails()
   Dim prop(1) as New com.sun.star.beans.PropertyValue

   forms = ThisComponent.Parent.getFormDocuments()
   conn = ThisComponent.Parent.DataSource.getConnection("","")

   prop(0).Name="ActiveConnection"
   prop(0).Value=conn
   prop(1).Name="OpenMode"
   prop(1).Value="open"

   oStartForm = ThisComponent.drawpage.forms.MainForm.SubForm
   
   articleCode = oStartForm.columns.getbyName("article code no").getstring
   supplierCode = oStartForm.columns.getbyName("supplier code no").getstring
   referenceID = oStartForm.columns.getbyName("reference ID").getstring
   
   print "article code: " & articleCode & ", supplier code no: " & supplierCode & ",   reference ID: "& referenceID   'OK working fine
   
   oNewDoc = forms.loadComponentFromURL("ARTICLE","_blank",0,prop())
   oNewDocForm = oNewDoc.drawpage.forms.MainForm
   
   IF oNewDocForm.isloaded = false THEN Wait 100 'allows faster CPUs to continue while waiting for slower ones
   oNewDocForm.Last
   oNewDocForm.First 'this along with .Last above leaves the total number of records in nav bar
      
   print "article code: " & articleCode & ", supplier code no: " & supplierCode & ",   reference ID: "& referenceID   'OK working fine

        ' This is not working!!!
   oNewDocForm.Filter = "article code no ='" & articleCode & "'"
   oNewDocForm.ApplyFilter = True
   oNewDocForm.Reload   
End Sub

Re: Open form, filter on recordID

PostPosted: Sun Mar 04, 2018 11:35 pm
by Villeroy
Works best without any macro code. Search this forum for "power filtering"

Re: Open form, filter on recordID

PostPosted: Sun Mar 04, 2018 11:46 pm
by UnklDonald418
Download the example shown here.
Filter/Search with Forms (leveraging SubForms)
it shows an example of filtering using 3 parameters without the brain damage of a macro.