[Solved] Sync MainForm with two SubForms

Discuss the database features
Post Reply
bugmenot111
Posts: 17
Joined: Fri Mar 26, 2010 12:14 pm

[Solved] Sync MainForm with two SubForms

Post by bugmenot111 »

Hi, I started yesterday with OO Base to create a Database for our young Students.

MainForm collects guardian details like Name, Phone Number, ID, Address, etc.

SubForms are:
PaymentsForm should collect ID, PaymentsAmount, PaymentDate.

And StudentsForm should collect FirstName, Birthdate, ClassID

The Problem:
120 MainForms Records are correct saved.
But the SubForms are saving all the same records related to the first MainForm till the last one.

Any Help :?:

PS. I tried to create Database without success, but OpenOffice Base :D
Last edited by Hagar Delest on Wed May 12, 2010 4:43 pm, edited 1 time in total.
Reason: tagged [Solved].
OpenOffice 3.1 on Windows Vista
ponlerd
Posts: 56
Joined: Sun Nov 15, 2009 6:22 pm
Location: Bangkok, Thailand

Re: Sync MainForm with two SubForms

Post by ponlerd »

But the SubForms are saving all the same records related to the first MainForm till the last one.
Can you explain a bit more, i don't understand your problem.
But 1 Mainform + 2 Subforms is possible to create in Base for sure.
OOo 3.2 Ubuntu 9.04 / OOo 3.2 Windows7 / Migrating from Access
bugmenot111
Posts: 17
Joined: Fri Mar 26, 2010 12:14 pm

Re: Sync MainForm with two SubForms

Post by bugmenot111 »

Hi ponlerd,

thanks for your replay.

OK try a bit more details of my concern.

MainForm got fields for the Guardians with their Names, Address and Phone Number.

1. SubForm contains fields for the students related to the guardians.

2. SubForm got fields for PaymentDate and PaymentAmount.

Now, when I create new records in the MainForm (Guardian) they are saved correctly,
that means each guardian with the correct Address etc.

But in the SubForms they always stay the same, that means:
Guardian: John Smith, has two Students, 2 payments received
Guardian: Alex Query, has 1 Student, no payment received

When I create new records for Alex Query I getting the same records in the SubForm from John Smith.

And thats the problem.
I want to get for each Guardian the right students and the right payments.

I hope thats easier to understand.
OpenOffice 3.1 on Windows Vista
ponlerd
Posts: 56
Joined: Sun Nov 15, 2009 6:22 pm
Location: Bangkok, Thailand

Re: Sync MainForm with two SubForms

Post by ponlerd »

I think you don't have the subform set up correctly.
In the form navigator, you should have it look like this
Forms
- MainForm
(indent)+ SubForm (the name doesn't matter, maybe SubForm1)
(indent)+ SubForm (the name doesn't matter, maybe SubForm2)
(indent) - other controls
(indent) - other controls
......
Now if you have something like this
Forms
- MainForm
(indent) - other controls
(indent) - other controls
-SubForm1
(indent) -other controls
(indent) -other controls
-SubForm2
(indent) -other controls
....
It's not going to work

Now suppose you have set it up correctly
Right click on the Subform1 on the form navigator and click properties
Go to the Data tab
set up Link Master Fields and Link slave fields so that both are the Guardian
Do the same with the second subform
and all should be ok

......
-
OOo 3.2 Ubuntu 9.04 / OOo 3.2 Windows7 / Migrating from Access
bugmenot111
Posts: 17
Joined: Fri Mar 26, 2010 12:14 pm

Re: Sync MainForm with two SubForms

Post by bugmenot111 »

Hi Ponlerd,

please see attachment.

I have changed the settings according to your instructions.

But still I am not getting the form way I want.

Each guardian should have different payments and students.
Attachments
Guadians, Payments and Students.odb
(24.65 KiB) Downloaded 176 times
OpenOffice 3.1 on Windows Vista
Cibes
Posts: 7
Joined: Fri Apr 30, 2010 12:55 pm

Re: Sync MainForm with two SubForms

Post by Cibes »

The problem is not with the form actually but with your tables. Once you understood the underlying concept it is really easy.
All the data is saved in those three tables "Contacts", "Payments" and "Students" you have created in the beginning. What is missing is some field for the computer the save which student or payment belongs to which guardian. Easy to fix though:
1.) Edit the tables "Payments" and "Students", to each one add a field of type INTEGER with a name like "contact_ID"
2.) In the main window go to Tools|Relationsships...
You will see your three tables and all their fields. Now drag the "ID" from "Contacts" onto the "contact_ID" of "Payments" and "Students". You will see lines connecting those fields. Next to the Contacts table there should be a "1", next to the other tables a "n".
Now you have given the computer a way to save which records belong to which contact. The "1" and "n" indicating that for one single guardian in "Contacts" there can be many ("n") payments and students.
3.) Edit your form again. You have done a little two much linking before. Now the correct link and master fields will be available: "ID" for "Contacts" and "contact_ID" for the payments/students table, this pair is enough you can (or rather have to) delete the others.

Hope this helps, feel free to ask again.
OpenOffice 3.2 on Ubuntu 10.04
bugmenot111
Posts: 17
Joined: Fri Mar 26, 2010 12:14 pm

Re: Sync MainForm with two SubForms

Post by bugmenot111 »

Hi Ponlerd,

thanks it works perfect.

I have just another 2 small questions:

1. I want to add of the Guardian fields "Reg. Date" automated datestamp.
The current date should appear, when I create a new record.

2. Is it possible to import data from a CSV or Spreadsheet file into the Guardian Table?

thanks a lot!
OpenOffice 3.1 on Windows Vista
ponlerd
Posts: 56
Joined: Sun Nov 15, 2009 6:22 pm
Location: Bangkok, Thailand

Re: [Solved] Sync MainForm with two SubForms

Post by ponlerd »

I think could you post two new posts for the two questions, so that other people can find them easily. I'll wait for your posts.
Ponlerd
OOo 3.2 Ubuntu 9.04 / OOo 3.2 Windows7 / Migrating from Access
Post Reply