Open form, filter on recordID

Creating and using forms
Post Reply
ccj.gmr
Posts: 3
Joined: Wed Feb 21, 2018 1:29 am

Open form, filter on recordID

Post 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

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
OpenOffice 4.1.5 on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Open form, filter on recordID

Post by Villeroy »

Works best without any macro code. Search this forum for "power filtering"
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
UnklDonald418
Volunteer
Posts: 1544
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Open form, filter on recordID

Post 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.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Post Reply