Problem with two ListBox in my form

Creating and using forms
Post Reply
ruzicka15
Posts: 1
Joined: Sun May 20, 2018 3:16 pm

Problem with two ListBox in my form

Post by ruzicka15 »

Hi, I am having problem with my ListBoxes in my form. I made one form with two listboxes to be able to search in the table, and one subform with the table itself. Listboxes work well when they are both filled with some data but I need them to work when is filled just one of them. For example if I would have a table with sex and hair-color and I fill just the sex listbox, it should show just males for example with all the haircolors. But in my case it show nothing when I leave one of the fields empty.
I hope you understood it and thank you for your advices!
OpenOffice 4.1.5. on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Problem with two ListBox in my form

Post by Villeroy »

Source of subform:

Code: Select all

SELECT * 
FROM "Table"
WHERE "SEX" = :paramSEX
  AND ("COLOR" = :paramCOLOR OR :paramCOLOR IS NULL)
link the parend form's fields to the child form's parameter names :paramSEX and :paramCOLOR.

The WHERE clause selects a record if the sex matches AND (if either the color matches OR the color is empty).
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply