Reload Form and Subforms

Creating a macro - Writing a Script - Using the API

Reload Form and Subforms

Postby ttt_1978 » Wed Jun 22, 2011 4:33 pm

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   Expand viewCollapse view
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   Expand viewCollapse view
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
ttt_1978
 
Posts: 36
Joined: Thu Dec 02, 2010 1:13 pm

Re: Reload Form and Subforms

Postby RPG » Wed Jun 22, 2011 5:28 pm

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 6.2.5.2 on openSUSE Leap 15
RPG
Volunteer
 
Posts: 2172
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Reload Form and Subforms

Postby ttt_1978 » Wed Jun 22, 2011 6:46 pm

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
ttt_1978
 
Posts: 36
Joined: Thu Dec 02, 2010 1:13 pm

Re: Reload Form and Subforms

Postby RPG » Wed Jun 22, 2011 7:25 pm

Hello

I cannot make it more clear then I did.

Romke
LibreOffice 6.2.5.2 on openSUSE Leap 15
RPG
Volunteer
 
Posts: 2172
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Reload Form and Subforms

Postby ttt_1978 » Thu Jun 30, 2011 3:32 pm

Anyone have the solution???
Windows XP/BrOffice 3.2
ttt_1978
 
Posts: 36
Joined: Thu Dec 02, 2010 1:13 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 8 guests