| View previous topic :: View next topic |
| Author |
Message |
PaulDG General User

Joined: 12 Mar 2012 Posts: 13
|
Posted: Wed Apr 04, 2012 4:23 am Post subject: Auto-populating records in a table. |
|
|
I currently have an employee database where I have a table with "basic details" along with a number of other tables on a "one-to-many" relationship using the <EmployeeID>.
Is it possible that when I create a new employee, using the "Basic Details" form, that a record is created in each of the other table? I guess it would just need to create a blank record with only the <EmployeeID> being added.
I suspect this has been asked before, but I'm not finding a solution when browsing though the topics.
Example I add Joe Smith, EmployeeID 101 in the "Basic Details" form and automatically a record is created in the "Address Details" table with just the <RecordID>, which is an auto-value field and EmployeeID "101. I'd fill in the rest later. _________________ Regards
PaulDG |
|
| Back to top |
|
 |
floris_v Moderator


Joined: 12 Jul 2007 Posts: 4603 Location: Netherlands
|
Posted: Wed Apr 04, 2012 5:16 am Post subject: |
|
|
I'd just put the address data in the same record (table) as the basic data, and enter them when you add an employee. Then you won't have to worry about programmatically adding records to tables. _________________ LibreOffice 3.6.3; OOo 3.4.1 on Windows Vista
Join the Official community forum - in several languages, including Nederlandstalig forum |
|
| Back to top |
|
 |
PaulDG General User

Joined: 12 Mar 2012 Posts: 13
|
Posted: Wed Apr 04, 2012 5:23 am Post subject: |
|
|
Thanks for the reply.
Unfortunately my example was a simplistic one. I also have contract, absence, appraisal, emergency contact and various other tables all of which will need to be pre-populated when a new employee is created. In addition to this, addresses can change so employees will have both current and old addresses.
I'm still hoping that there is a way that filling in a form can create a "barebones" record in all of the related tables. _________________ Regards
PaulDG |
|
| Back to top |
|
 |
Billyray OOo Enthusiast


Joined: 06 Mar 2007 Posts: 144 Location: Lake Erie's Shore in Ohio
|
Posted: Thu Apr 05, 2012 6:02 am Post subject: |
|
|
Is a barebones record just one that has the foreign key: EmployeeID?
Are all of the subforms on the mainform? If they were, your suforms would already have a new record ready with the foreign key, but the record would only be created if something actually was entered into the subform's record.
If the subforms are not all on the same main form, are they individually called up? How? _________________ Billyray
using:
Linux distro: Ubuntu 10.04 LTS, Lucid Lynx, OOo Base 3.3, connected to MySql database using Java jdbc (note: ONLY sun-java-6-1.6.0_22 jre works right), and converted from MS Access 2003. |
|
| Back to top |
|
 |
|