Page 1 of 1

Problem with two ListBox in my form

PostPosted: Sun May 20, 2018 3:30 pm
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!

Re: Problem with two ListBox in my form

PostPosted: Sun May 20, 2018 4:53 pm
by Villeroy
Source of subform:
Code: Select all   Expand viewCollapse view
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).