Auto-populate table with default values via form

I have a question about working with the table control on a form. The attached database shows my setup. On the ClassAssignment form I have listboxes that let me populate the fields in the tblMapClassEntryExbtr table. I’d like to auto-populate the Exhibitor field with a default entry from the tblEntries table when an item is selected from the Entry listbox pulldown. Then the default Exhibitor can be overridden with the Exhibitor listbox pulldown if desired. Is there a relation that would accomplish this? Or does it require Macro support? Or am I totally going down the wrong track?

MinDemo.odb (44.9 KB)

Hello,

Why do you even need the exhibitor field? The value seems to already be in the Entries table.
Edit:
A bit more thought given. Right now I can only see this working with a macro. Get the value from the Entries table using a result set in the macro. Examine the Exhibitor list box entries to see what index number this is and then set the list box to the index.
.
The confusion here is not knowing just what is happening. Seems there are multiple meanings for Exhibitor.

I’m trying to put together a management system for a livestock show. Each Class is associated with one or more Animals. The animals may be associated with multiple classes. Each animal is associated with one or more Exhibitors. An Exhibitor may be associated with multiple animals.

Well, the terms don’t make sense to me but regardless you would need a macro as I noted earlier.

Typically, an exhibitor will be associated with several animals. I have this noted by the Exhibitor ID field in the Entries table. For a class, this exhibitor will normally be assigned, but occasionally another exhibitor may show the animal in a class. I want to have the database automatically apply the default exhibitor when classes are being defined. It seemed to me that a macro might be required, but I wanted to ask incase there might be some capability I was missing. Thanks for your help.

I’m having some difficulty with the macro. Where can I find a data model to see how to address he controls on my form? I’ve looked in the OOME and Chap 9 of the wiki, but they seem to be out of date. The examples don’t work on my database.

oDoc = thisComponent
oDrawpage = oDoc.drawpage
oForm = oDrawpage.forms.getByName(“ClassAssignment”)

This fails with an “Property or method not found: drawpage” error.

the correct line is:
.

	oForm = ThisComponent.Drawpage.Forms.getByName("MainForm")

You have used the external form name of “ClassAssignment”. This statement needs the internal form name. A Base form can have many internal forms and each for can have sub forms and those sub sub forms, etc.
.
Each form may be attached to a different data set.
.
OOME has a lot of good info but takes a lot of reading & re-reading. Also there are other Pitonyak documents > Pitonyak Page
.
Then a must have for object inspection is MRI > [Tutorial] Introduction into object inspection with MRI
.
And there is more scattered around.
.
So once you have oForm you can access the table control with:

oField1 = oForm.getByName("MainForm_Grid")

and then with MRI installed you can examine it.

@lcorley
This should also be of help > StarOffice_7_Basic_Programmers_Guide

Thanks for the MRI reference. That helped a lot with understanding the data structure.
I’m now able to access the desired form, and inspect its contents.

Leon

I got it working. Thanks again for all your help. Attached sample for your amusement.
Leon
SampleShow2.odb (133.2 KB)