Page 1 of 1

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

Posted: Thu Sep 04, 2008 9:46 pm
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...

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

Posted: Mon Sep 08, 2008 4:09 pm
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

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

Posted: Mon Sep 08, 2008 4:12 pm
by Villeroy
Just a side-note:
... Base as a replacement for MS Access.
May be 5 years from now.