Ask Your Question
0

I need help creating a combo box in a form in base

asked 2015-05-22 04:34:39 +0200

zipster1967 gravatar image

updated 2015-08-26 21:36:58 +0200

Alex Kemp gravatar image

I am using LibraOffice version 4.4.3.2 Base

I have a table for categories with 3 fields The ID field a category field and a parent category field. The parent category field contain the ID of the table record for the category I want listed as the parent of the category of the current record. For example: ID Category Parent Category 0 Meat -NULL- 1 Frozen -NULL- 2 Fresh -NULL- 3 Fruit 2 4 Fruit 1

So if I wanted an item listed as being in the Fresh Fruit category it would have a category in the items table of 3 But I am not sure how to create a combo box for the parent category field in a form to let me select a category from the table in the parent category field. Can anyone help me accomplish this?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2015-05-22 06:36:49 +0200

JohnSUN gravatar image

updated 2015-05-22 07:06:53 +0200

Did you mean something like this?

SELECT DISTINCT "Name", "ID" FROM
  (SELECT "CategoryID" "ID", "CategoryName" "Name" 
     FROM "Categories"
     WHERE ("ParentID" IS NULL) 
 UNION ALL
   SELECT "A_2"."CategoryID" "ID", "A_2"."CategoryName" "Name" 
     FROM "Categories" "A_1", "Categories" "A_2" 
     WHERE "A_2"."CategoryID" = "A_1"."ParentID")

So, if you insert something as "8-Apple-4" then you can see subcategory "Fruit" from category "Frozen" in the list.

NB. It must be ListBox, not ComboBox! Set this SELECT to "List content" of this control

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-05-22 04:34:39 +0200

Seen: 153 times

Last updated: May 22 '15