Macro - Open a form from another form

Hi all, this is my problem:

  1. I have a form that read data from my “CLIENTI” table. The name of my customer is showed in a textBox.
  2. I’ve created a Macro where i get the current value of that textBox and I’m trying to pass that value to another form that is created using a Query.

So, my code so far:

Dim oForm As Object
Dim frm_container As Object
Dim FormModel2 As Object
Dim oCrrV As String

oForm = ThisComponent.Drawpage.Forms.getByName("MainForm")
Dim oPutField As Object
oPutField = oForm.getByName("frm1_tbox_Nome")
oCrrV = oPutField.getCurrentValue


frm_container = ThisDatabaseDocument.FormDocuments.getByName("testu")
frm_container.open
FormModel2 = frm_container.component.getDrawPage.getforms.getbyindex(0)
FormModel2.Filter = "(""RelationQuery"".""Nome Uomo"" like '%" & oCrrV & "%')"
FormModel2.ApplyFilter
FormModel2.reload()

My Query is called “RelationQuery” and it has 2 columns (calculated by the combination of a number of fields from different tables). As you can see in my code one column is called “Nome Uomo”.

This Macro is beign called by a button that should open the form and filter it with the data i want but it shows me always an error:

Error code: 1

firebird_sdbc error:
*Dynamic SQL Error
*SQL error code = -206
*Column unknown
*RelationQuery.Nome Uomo
*At line 1, column 321
caused by
‘isc_dsql_prepare’

Do you know where is the error?

Hello,

Have tried various methods to duplicate based upon your code any do not get any error.

Based upon that and the error you have posted, either testu is not the correct form or the form has more than one form internally and 0 is not the correct internal index for that table/query.

Hi! I got the solution.

My other form was created using a “Query”. The column “Nome Uomo” was done by the combination of 2 fields “Nome” + “Cognome” so i change my code in this way:

From:

FormModel2.Filter =
“(”“RelationQuery”"."“Nome Uomo”" like
‘%" & oCrrV & "%’)"

To:

FormModel2.Filter = “((”“B”"."“Nome”"
|| ’ ’ || ““B””."“Cognome”") LIKE ‘%"
& oCrrV & "%’)"