Base subform: How to create product recipe input form?

I am quite new to databases. I am creating a products datbase, where I have a table for products and table of ingredients. Then I have third table for product recipes with the following fields:

ID
ID_Product
ID_Ingredient
Amount_ingredient
Unit_amount

I need to create a form, where I can select a product from a listbox. Then I would need to specify its ingredients and their quantities and the measurement unit of each ingredient. There may be 1-50 different ingredients for each product.

I don’t understand how can I create such a form, where I can add ingredient lines. Is it possible to for instance have a button: “Add ingredient”, clicking of which would add a new ingredient entry line? Or what is the best way to accomplish this?

Hello,

This is the basis of relational databases. Your Products table is primary and the recipes are linked via one of the fields in the record back to each product. The recipes can have any number of records linked back to the one product. This is a one-to-many (Product-to-recipe) relationship.

With that, you have on a form (external), a main form(internal) which is the Product and a sub form (recipes) which has a property to link associated records back to what is shown in the main form. However, you also state you want a listbox to select the product first. This can be done using table filtering. To accomplish this, here are some posts with links to information and sample Base files: display specific record in a form, and how to put a search box into a LO Base form.

Also, you should read the LO documentation which has many good examples and many details about forms and sub forms. The documentation is found here → LibreOffice Base Handbook

Your problem seems similar to what I had with food recipes.

I put an example database up in LibreOffice Templates some time back. It may be of some help to you to download and study it. It uses tables to handle recipe ingredients, units of measure, quantity, etc.

It is available here-> MyRecipes

Download and unzip the files. Open the database in LO Base. NOTE: you don’t have to run the macros to use it.

I hope it helps.

i’ve downloaded this but can’t get it to work at all