Using a button to open a new form (plus determine its query)

Creating and using forms
Post Reply
CGHPaul
Posts: 1
Joined: Thu Sep 04, 2008 9:38 pm

Using a button to open a new form (plus determine its query)

Post by CGHPaul »

I realize this has been asked a few times, but I don't think I've ever seen the full explanation of how this is done...

I want to use a form with a button on it that will not only open another form, but determine the new form's query.

In essence, I want to use the source form's data to determine what some of the criteria is for the destination (the new) form's query.

Can this be done? And if so, how?

The answer to this will probably determine if I can accomplish the goals I have in mind with using Base as a replacement for MS Access. I'm a Linux user and I want to get as far away from MS as possible.

Anyone's help in this matter is EXTREMELY appreciated.

Thanks...
OOo 2.3.X on PCLinuxOS
QuazzieEvil
Volunteer
Posts: 283
Joined: Tue Dec 04, 2007 6:38 pm
Location: Houston, TX

Re: Using a button to open a new form (plus determine its query)

Post by QuazzieEvil »

In addition to steps to open form, supply a filter string. Here is an example:

Code: Select all

Sub openForm(FormName As String,Connection As  Object,Optional Filter As String, Optional FormToFilter As Integer, Optional GotoRec As Integer)
	Dim FormDoc As Object
	Dim Form As Object
	Dim FormDocs As Object
	Dim Args(1) As New com.sun.star.beans.PropertyValue
	
	FormDocs=Connection.Parent.DatabaseDocument.FormDocuments
	If IsMissing(Filter) Then
		Filter=""
	End If
	If IsMissing(FormToFilter) Then
		FormToFilter=0
	End If
	If IsMissing(GotoRec) Then
		GotoRec=-1
	End If
	
	Args(0).Name="ActiveConnection" : Args(0).Value=Connection
	Args(1).Name="OpenMode" : Args(1).Value="open"
	
	FormDoc=FormDocs.loadComponentFromURL(FormName,"_blank",0,Args())
	If Filter<>"" Or GotoRec>=0 Then
		Form=FormDoc.DrawPage.Forms.getByIndex(FormToFilter) 	
	End If
	If Filter<>"" Then
		Form.Filter=Filter
		Form.ApplyFilter=True	
	End If
	If GotoRec>=0 Then
		Form.load()
		If GotoRec=0 Then
			Form.moveToInsertRow()
		Else
			Form.absolute(GotoRec)
		End If
	End If
End Sub
User avatar
Villeroy
Volunteer
Posts: 31345
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Using a button to open a new form (plus determine its query)

Post by Villeroy »

Just a side-note:
... Base as a replacement for MS Access.
May be 5 years from now.
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
Post Reply