I have a table which contains several picture collumns. When I open the the form to upload pictures, Base automatically starts to download the pictures of the first 41 records. How can I disable the automated (down)load of the (by default) selected records after opening the form? In the current situation I have to wait several minutes before Base has downloaded all the pictures of the first 41 records. This problem will probably become worse as more records have their images uploaded.

I need that Base only downloads the record (including several multi-MB image files) when I search for a specific record, for instance by a 'form based filter' or another filter method. How can I make this work?

I am using LO Base 6.0.3.2 Build ID: 1:6.0.3-0ubuntu1 connected to an online MySQL database through driver: mysql-connector-java-5.1.45 on Xubuntu 18.04

edit retag close merge delete

Sort by » oldest newest most voted

Hello,

Unfortunately this answer is not much better than the last.

Records for a form are retrieved based upon a default internal setting called FetchSize. This default is set to 40.

The good news it that it can be changed. The bad news (only because of your comment in another question) is that it needs to be changed via a macro. For the sake of completion, here is the macro:

Sub RecordsRetrieved
Dim oForm As Object
oForm = ThisComponent.Drawpage.Forms.getByName("Your_Internal_Form_Name") REM usually MainForm
oForm.FetchSize = 1
End Sub


You would need to use your internal form name as noted in the code. This macro is then run by attaching it to the Open Document event of the form.

Edit 2018-08-26:

Have done some further testing with LO v 6.1.0.3, MySQL v5.7, JDBC 8.0.12 connector on Mint 18.3, 4 gb memory, quad CPU @ 3.2

Performed the same testing using linked images. There was no delay using any of the forms and memory was never an issue.

more

You tempted me to try the world of macros. I found out what 'internal form' is and I found out how to create events and assign them to events.

When I create the macro and run it by clicking the button in the macro editor, I get the error:

BASIC runtime error. Property or method not found: Drawpage

When I open a form which contains an internal form called MainForm it still loads up to 40 records (so it's not working), but it does not create an error dialog.

( 2018-08-26 14:58:04 +0200 )edit

I used the following: Sub RecordsRetrieved Dim oForm As Object oForm = ThisComponent.Drawpage.Forms.getByName("MainForm") oForm.FetchSize = 1 oForm.reload() End Sub

( 2018-08-26 15:00:23 +0200 )edit

I expect that the 'open document' is not the right trigger to be used. I added a MsgBox to the macro in order to find out at what actions/events it was triggered. I found out that it was run upon opening the .odb along with display of the above mentioned error message. However, upon opening a form containing an interal form called "MainForm" the macro was NOT run.

Perhaps I need a different event/trigger to assign the macro to, but I don't know which.

( 2018-08-26 16:29:11 +0200 )edit

@impocta First, the error. The macro is designed to be run from a form and not the editor. Running from the editor would require much different code. The code you used appears to be the same as what was presented.

It appears you may have attached the code to the wrong Open Document event. There is one for the .odb and another for each form individually. This needs to be attached to the form it applies to.

( 2018-08-26 17:26:40 +0200 )edit

Remove the attachment to the .odb event. Open the form needing this in Edit mode. Now select Tools->Customize and attach to the Open Document event there. This should resolve your problem. If you are still having a problem, a sample can be provided. I do attempt to test what I post and this works on my end without a problem.

( 2018-08-26 17:30:10 +0200 )edit

I did indeed attach it to the wrong 'open document'. I tried it again by opening a form containing MainForm and then tools->customize->events and attach the macro to open document.

Now it runs, however the macro does not have the desired effect. When run on form connected to a table with large files in it the following happens. Upon opening the form it first freezes for a few minutes, then my macro confirmation dialog pops up, then if freezes again and later the number 41 changes to 2.

( 2018-08-26 23:13:01 +0200 )edit

It looks like the macro is run too late to prevent the first 40 rows from being downloaded.

When used with a table with few bytes of data in the first 40 rows, this delay will probably go unnoticed because the switch from 41 loaded to 2 will happen quickly.

Is there any way to change anything in the basic configuration of Base to change the 40 to a lesser number? If that's not the case, I can maybe make the problem less bothering by creating a separate table for the images.

( 2018-08-26 23:19:07 +0200 )edit

Another interesting note, using MySQL Workbench to view records works similarly. Every image brought on screen uses more memory and the memory is not released until Workbench is fully closed.

BTW I believe the "40" rows is built into the source code. Most likely would need to find, change and re-compile to limit to one. This then would affect ALL forms.

( 2018-08-27 04:26:25 +0200 )edit

@impocta If you are still looking for a method, see this answer for possible workaround -> Base Prevent Form Execute on Page Launch

( 2018-11-24 04:16:10 +0200 )edit

@Ratslinger I see that I can prevent a large retrieval of data upon opening the form by leaving the form source table in the data tab empty. However, i do not understand how to use a macro to automatically add the source table and decrease the fetchsize. Could you explain?

( 2018-12-13 09:18:45 +0200 )edit