We will be migrating from Ask to Discourse on the first week of August, read the details here

# Macro insert data into table control @dialog

Hello, i am new at macros and try to write some small application, some customized address book.

whats working:

• open an dialog

• connect to the database

• fill name from database in list box

• read the details from the selected name from the database

whats not working:

• i want to write the table header as first column in an table control

• i want to write the selected name, dataset (details) into the second column in an table control

sorry for the bad basic style its my first try and basic prg.

questions:

• how can i fill an table control in an dialog?

where can i get more macro information about functions, and methods? i found some documents, pdfs and odts, but all are not complete. is there anywhere some api information about all elements in basic? i found nowhere information about functions on an table control object.

edit retag close merge delete

Hello,

Please check and possibly replace your attachments. The Base file contains a table with two records - that is all. The Writer file is completely blank. Nothing anywhere about any source code.

Please provide an example of what actual type of data you are trying to write. Your whats not working: is not clear. Also not clear is how can i fill an table control in an dialog?. Table controls are not used in dialogs. In fact, any controls used in dialogs are not data aware. This is to be done with macros (time consuming learning process).

While expecting some response (please use comments or edit question with the information - do NOT use an Answer), Here is a link to a list of various Base info -> To learn LibreOffice Base are there introductions or tutorials?

( 2020-12-09 18:19:26 +0200 )edit

Hello, have you check the macros at the odt file? the database is an example and contains only 2 fakes datasets. if i open the file, the odt is empty, but inside are macros. i am talking about macros. i fill an list control with data, and now i want to fill an table control with data, but i dont know how do to that.

( 2020-12-10 08:19:01 +0200 )edit

Sorry, i will reupload the odt with the macro. WIP

( 2020-12-10 08:50:20 +0200 )edit

new odt file is up, i should now contain the macro, sorry for that

( 2020-12-10 10:08:14 +0200 )edit

Sort by » oldest newest most voted

hello, its working thanks for the help. i dont use a table i use an list box and that is really easy

rvalue = get_addresses(id, company)
IF rvalue THEN
c_id% = UBound(id())
c_company% = UBound(company())
IF  c_id% > 0 And c_company% > 0 And c_id% = c_company% THEN
END IF
END IF

more

Hello,

It appears you have not read my comment very well. It does state:

Table controls are not used in dialogs.

There is a control that is similar but it must be constructed from scratch using macro code. That is a Grid Control. Like all other controls in a dialog, it is NOT data aware. It is up to the user to manipulate ALL data used in ANY control in a dialog. There are only bits and pieces scattered about the Grid Control. Here is the largest single item -> UNO Grid Control. Here is some further info on Dialogs.

Have already given you a link in my comment to many other Base references (includes macros & more).

Also, there is a sample of a Grid Control in my question (NOT in the Answer) on this post -> Looking to create grid (not table) control on Base form.

Looked again at the original post of the .odt document from you - no code there. In the second post, the code was there. You should explain what you are doing instead of having others fumble around trying to guess. It appears this is something for Writer. You are accessing a REGISTERED (never mentioned) database.

Edit:

Another sample in this post -> Calc BASIC | How to alter the previously opened dialog to be active ? And is there double click event for grid in dialog?. Although this is using Calc, it does demonstrate double clicking an item in the grid control and having that value be placed in a cell on a worksheet.

more

Have seen the icon you are referring to in the IDE for dialogs. Hovering over it states -Table Control. However, it is not a table control. It is actually a grid control (graphical form of that mentioned in answer). I do not find any documentation on this and do not know if or how it works. Will try to use MRI to examine.

Edit: Initial reaction is that this is not fully implemented.

( 2020-12-11 05:47:57 +0200 )edit

Have taken a closer look at the control. As it sits, there is a lot of additional code to be implemented with this control to get it to work as the grid control in my answer does. I takes much the same code and more work to integrate it.

This control is not ready for strictly graphical use.

Use the Grid Control mentioned in my answer.

( 2020-12-11 07:07:46 +0200 )edit

Contrary to initial reaction, took another look at the control. Although I could add columns and insert data, attempts to set a size on the column width would fail and reset itself leaving the user to manually adjust each time. Additionally, to try and overcome that, setting scroll bars would not work. They could be seen in the design, work in the test display but would not appear when the dialog was executed. Furthermore, they would disappear once the document was closed & re-opened.

Failure on multiple fronts. Probably other situations. Best to stick with coding from scratch.

( 2020-12-12 03:58:34 +0200 )edit