Ask Your Question
0

Macro - Open a form from another form

asked 2020-09-12 12:55:51 +0100

UnDon3 gravatar image

updated 2020-09-13 03:53:12 +0100

Ratslinger gravatar image

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?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2020-09-13 21:19:38 +0100

UnDon3 gravatar image

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 & "%')"

edit flag offensive delete link more
0

answered 2020-09-13 04:24:21 +0100

Ratslinger gravatar image

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.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-09-12 12:55:51 +0100

Seen: 64 times

Last updated: Sep 13 '20