Form to Subform question about primary keys

Creating and using forms
Post Reply
wjg
Posts: 27
Joined: Wed Apr 02, 2008 12:56 pm

Form to Subform question about primary keys

Post by wjg »

What is the terminology, or what "feature" has been implemented, so that I understand what is happening with the form so I can better understand it.

I created a table of "Jobs", and created a SubForm to enter data for a table named "WorkSched," they both share data - JobID

I had previously created a relationship between the two tables, the JobID is a primary key in "Jobs", and created the relation to the WorkSched table's field of JobID. I enter data into the Jobs fine, and I thought I would have to create a tricky subform to enter several employees into the WorkSched table for each job that exists.

The subform which is based on the "WorkSched" table, only counts as many records that I have entered for each JobID in the navbar control I created, and the JobID stays the same for each new "WorkSched" record I create until I advance the mainform's records for "Jobs." Does this occur because of the primary key relationship? I am glad its happening, I just didn't expect to see the the form work this way (I am a super noob when it comes to databases). But if its not because of the relationship, then I need to know what it is.
User avatar
kabing
Volunteer
Posts: 680
Joined: Fri Nov 23, 2007 12:05 am
Location: Midwest, USA

Re: Form to Subform question about primary keys

Post by kabing »

It happens because of the defined master/slave field relationship between the main form and the subform. To see what I'm talking about, open the form in Design view (right-click on the form icon and choose Edit). Right-click on an element that is part of the subform (it sounds like it might be a table in your case?) and choose "Form..." from the contextual menu. In the preferences window that opens, you will see fields for defining the master and slave fields for the main and subforms. Base then automatically enters the correct value into the slave field in the subform.

If you created the form with the wizard, the wizard took care of all of this for you based on the information you provided in the wizard panes.

kabing
NeoOffice 2022.7 LibreOffice 24.8.4 on (Intel) Mac OS Ventura
milgner
Posts: 1
Joined: Tue Jul 15, 2008 4:01 pm

Re: Form to Subform question about primary keys

Post by milgner »

Hi,

I'm having the same problem. I'm running OOo 2.4.1 on WinXP. My setup is as following:

1) A query which returns a list of ISRCs
2) Another query which contains artist/title information for those ISRCs

First, I want to display data only. I created a form with a sub-form using the wizard. The two forms are linked via the "ISRC" column.
However, the field in the sub-form displays only data from the first record, even when I navigate the main form to another record.
During the last years I have been working with quite a number of database platforms and developing on a couple of environments but somehow I can't get OOo Base to properly work for me :cry:
OOo 3.0.X on Mac OSx Leopard + Windows XP Professional SP3
Post Reply