How to create a method of searching databases, without creating a new query every time?

For arguments sake I work in a “real estate” office. I want to create a database of several buildings, with records of all the residents in each building and all the contractors that work on each building. I’m trying to construct a reusable method of searching for a resident or contractor without creating a new query every time.

I’m envisaging something that looks like a form, with a “search” and “clear” button.

Forgive my possibly obvious question, I am new to databases.

You will need to study FORM-BASED FILTERING techniques. The standard form-based filter buttons at the bottom of your FORM (see attached screenshot) will likely do the job, but if you need more flexible techniques try DACM’s examples as a good starting point. Essentially these extended methods allow you to type in (or select from drop-down lists) various search critieria (e.g. someone’s name), and a linked sub-form will show you all the results (or a single result if there is only one).

form-based filter button.png

(edit: activated screenshot)

Simplest way is to create a query that generates a dialog prompt. As a constraint in the query, type a placeholder name to identify the value, preceded by a colon ( : ), i.e, :enter_variable . When you run the query, you will get a dialog box that requests the value for enter_variable, and then displays the query using the variable you entered into the dialog box. It will look like this:

image description

The query can be used as the source for the form. h/t Nocton@ooForum

Push button would be more sophisticated. For some detail about programmatically navigating through records in a form, see LO form Q/A Open form via macro in Libreoffice Base.