Reload Form and Subforms

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
ttt_1978
Posts: 36
Joined: Thu Dec 02, 2010 1:13 pm

Reload Form and Subforms

Post by ttt_1978 »

I have a form in OOO Writer that manipulates data from OOO base database through SQL statements.
When I first built the form, it had a single subform, some textfields and some buttons.
To insert data into the textfields and into the subform, I used Dialogboxes that were executed by the main form buttons.
When the user filled the Dialogbox fields and pressed the button save, the form execute the SQL statement and the main form was reloaded.

Code: Select all

Sub DIALOG_SAVE_BUTTON()
    ...
    Dim StrSQL As String
    StrSQL = "UPDATE ""TABLE_1"" ..."
    Statement = ExecuteQuery(StrSQL)
    Dialog.EndExecute()
    Form.Reload
End Sub
This code worked perfectly for a long time.
However, I needed to insert another subform into the Main Form.
That was the start of my problems.
When I created the second subform the line "Form.Reload" stop working.
Few days ago I find out that the reload method works only if you focus the form.
Thus, for the subforms it works ok. I change the focus for the subforms, run the reload method and the rows are refreshed.
Somethin like this:

Code: Select all

Function RELOAD_ALL_FORMS()
    ...
    DocumentView.getControl(SUB_FORM_1_GRID).setFocus()
    CtlSUB_FORM_1.Reload
    DocumentView.getControl(SUB_FORM_2_GRID).setFocus()
    CtlSUB_FORM_2.Reload
Form.Reload
End Function
But the "Form.Reload" still not working. I tried to set focus to a control in the form, I tried to set focus on the form via formcontroller.GetByName("FORM").SetFocus(), but nothing seems to Work!!!
The interest thing is that if I create a button in the main form to execute the function "RELOAD_ALL_FORMS", the form is reloaded after cliking it for a couple of times.
But I don't want this button. I want to reload the form automatically!!
What am I doing wrong??

Please Help me!
Windows XP/BrOffice 3.2
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Reload Form and Subforms

Post by RPG »

Hello

There is no need that a form must have focus when you want reload it. It can be you have designed your macro in that manner. A forms must be accessed good. See in the form navigator how your forms are designed.

I have the idea you give real important parts not of your code. When you work with events then it can be that you no longer accessed the form you want accessed.

I think you have to study better what you can do with databases and also with OOo-base. Using the macros you do now makes it real difficult to change some thing in your forms.

Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
ttt_1978
Posts: 36
Joined: Thu Dec 02, 2010 1:13 pm

Re: Reload Form and Subforms

Post by ttt_1978 »

RPG wrote:Hello

There is no need that a form must have focus when you want reload it. It can be you have designed your macro in that manner. A forms must be accessed good. See in the form navigator how your forms are designed.

I have the idea you give real important parts not of your code. When you work with events then it can be that you no longer accessed the form you want accessed.

I think you have to study better what you can do with databases and also with OOo-base. Using the macros you do now makes it real difficult to change some thing in your forms.

Romke
Hi Romke,

Sorry, I didn't get your point.
Windows XP/BrOffice 3.2
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Reload Form and Subforms

Post by RPG »

Hello

I cannot make it more clear then I did.

Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
ttt_1978
Posts: 36
Joined: Thu Dec 02, 2010 1:13 pm

Re: Reload Form and Subforms

Post by ttt_1978 »

Anyone have the solution???
Windows XP/BrOffice 3.2
Post Reply