How can I add values to a table using a button?

Hello guys,
I have started using Base recently and so far I haven’t had any trouble, but I am facing a task which I am currently unable to solve.
I have two main tables: EVENTS and CAUSES (each table has two fields: ID and description).
Each EVENT can have multiple CAUSES and viceversa. This is why I have created a third table (RELATION_EVENTS_CAUSES), which contains two fields: ID_EVENTS and ID_CAUSES.

I have created a form, using some macros, which allows me to:

  • Select an element from EVENTS table (Main Form 1, grid control with 1 text column)
  • Add elements to CAUSE table (Main Form 2, grid control with 1 text column)
  • Link causes to the selected event in RELATION_EVENTS_CAUSES (Sub Form 1, grid control with 1 listbox).

Using macros I was able to update the list box in Sub Form 1 whenever I add, remove or modify an element of CAUSE table but this is becoming impractical when the number of elements starts growing.

This is why I have thought to eliminate the Sub Form 1 grid control and replace it with a button (actually I would probably keep the grid control, but for display only)
Ideally, I would select one event on Main Form 1, one cause in Main Form 2 and use a button to add a record to RELATION_EVENTS_CAUSES, with the IDs of the selected elements.

I am not really looking for a ready-made solution, but I would like to know from people more experienced than me if this is feasible, if it’s gonna be hard or not, or if there are simpler solution to this task.

Thank you very much!

Hello,
Do not see a reason for your needing a macro.
Based upon your explanation, SubForm1 can be its own main form using table RELATION_EVENTS_CAUSES. As a sub form it is linked to the main form and automates the linkage. But you seem to say you want to handle this differently.
.
It would have two list boxes - each displaying the description of EVENTS or CAUSE and each storing the relative ID. Then you simply start entering the description until it is displayed. There is no need for any scrolling or searching. By your stated method you need to find each of these in the other forms anyway.

Yes, this was my original implementation and it works. I was looking for something nicer, but the more I look into it the more complicated it seems, so I guess I will stick to your proposal, unless I find a smarter way to do it. Thank you!