Edit the properties of a combo box. In the Data tab for Type of list contents
, specify SQL [Native]
. For List content
, specify the following query:
SELECT 'No' FROM DUAL UNION SELECT 'Yes' FROM DUAL
That is if the engine is Oracle. For MySQL, only this is needed:
SELECT 'Yes' UNION SELECT 'No';
For the embedded HSQLDB engine, version 1.8 requires a special table to be created.[1] Create a table called MY_DUMMY
with only one column and one row. This will behave like Oracle's DUAL table. Then specify the query like this:
SELECT 'No' FROM MY_DUMMY UNION SELECT 'Yes' FROM MY_DUMMY
[1] In newer versions of HSQLDB, it is possible to use (VALUES(0)) as a dummy table, but LO uses the older version by default.
[2] UNION combines two SELECT statements.
EDIT:
Here are step by step instructions using Apache OpenOffice 4.1.2. All tables and fields are upper case to make SQL easier.
- In OpenOffice, go to
File -> New -> Database
.
- Radio
Create a new database
.[3] Next.
No, do not register the database.
Finish
. Save the file somewhere.
Create Table in Design View
.
- Field Name:
ID
. Field Type: Integer [ INTEGER ]
.
- Right-click to the left of
ID
and specify Primary key
.
- Save as
MY_DUMMY
and then close the table.
Create Table in Design View
.
- Again create an
ID
field as primary key.
- Also create a field called
VALUE
as type Text [ VARCHAR ]
.
- Save as
MY_TABLE1
and close.
- Double-click on table
MY_DUMMY
and add one record with value 0
.
- Press enter to save the record, then close the table.
- Double-click on table
MY_TABLE1
and add two records with ID
of 0
and 1
.
- Set the
VALUE
field to No
for both records and close the table.
- In the
Forms
area, Use Wizard to Create Form...
Tables or queries
: Table: MY_TABLE1
.
- Click
>>
to move ID
and VALUE
to the right side.
- Press
Finish
, then close the form.
- Right-click on the
MY_TABLE1
form and choose Edit
.
- With the Combo Box tool, drag a large square to create the combo box.
- Press
Cancel
to close the wizard.
- Right-click on the combo box and choose
Control
.
- In the
Data
tab, for Data field
, specify VALUE
.
- For
Type of list contents
, specify Sql [Native]
.
- For
List content
, specify SELECT 'No' FROM MY_DUMMY UNION SELECT 'Yes' FROM MY_DUMMY
.
- Save and close the form.
- Double-click to open the form.
- In the combo box, click
Yes
.
- At the top of the combo box, click to the right of
Yes
to move the cursor there.
- Press
Enter
to accept the value of the combo box.
Now you should see the value in the table change to Yes
.
[3] This option uses an embedded database, which is not recommended for production environments, only for testing and development. The engine is HSQLDB 1.8.
What engine are you using? For example the default HSQLDB 1.8. – Jim K – 2016-07-19T00:45:10.097