Use a macro to add a record to a table in Base

In the database I am making, I have a table “documents” and a table “categories”. These two are joined to a third–“documentcategories”–by a primary-foreign key relationship.

On the data-entry form, I want to have a series of checkboxes, one for each category. When the user checks one, I want to add a record to the “documentcategories” table, associating the current documentID with that particular categoryID.

My question: Is this possible to do entirely in the form, or do I have to use a macro? Is it possible to do even with a macro? If so, how would I go about it?

Any help on this is appreciated.
-AnthonyP

to use SQL in an event-handler macro:

Sub Main(event as object)
dim Form,Connection,SQL as object
Form = Event.Source.Model.Parent
Connection=Form.ActiveConnection
SQL=Connection.createStatement()
SQL.executeQuery(“querey goes here”)
End Sub

I believe you might only be able to do that in a macro associated with the object. I know Libreoffice uses UNO for extensions, and possibly for macros as well. You might want to look into that.
There is also some interesting looking posts on this forum that may be of some help:
http://user.services.openoffice.org/en/forum/viewforum.php?f=20