Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 30th, 2006, 05:12 PM
Authorized User
 
Join Date: Sep 2003
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default Create Related Records

I am developing a human resources application in Access 2002 (VBA). After the user adds the personal information for a new employee, I want the program to automatically add that new employee's EmployeeID to 6 additional, related tables. This will allow the user to click a button on the main employee form and go to another form to input data such as "Emergency Contact." When the user clicks the button ("Emergency Contact")to input information on the new employee, I want the "Emergency Contact" form to pull that person's record, which presumably will have nothing bu EmployeeID. I've got that code to work fine. I need to know how to have Access to automatically place the EmployeeID in these other tables.

Any suggestions?

Thanks in advance

David

 
Old October 31st, 2006, 09:16 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there..

since you are working with access, you will have to do it by yourself. Access lack any facility to do that kind of things (like triggers or Store procedure). So you will have to do the inserts in all the related table. And don't forget to use a transaction.

HTH

Gonzalo
 
Old October 31st, 2006, 06:51 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Gonzalo is essentially right, but if you do your data entry using a form, you can use events in the form to run code that will do what you want. Forms have the following events:
Code:
BeforeInsert User types the first character in a new record. 
BeforeUpdate User updates the record. 
AfterUpdate  Record is updated. 
AfterInsert  Record updated is a new record.
One or more of those should do the trick for you.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting one of possibly many related records rodmcleay SQL Server 2000 2 March 24th, 2007 12:49 AM
automatically create new records scandalous Access VBA 3 February 27th, 2007 03:08 PM
create one string from various records paul20091968 Access VBA 1 January 4th, 2007 04:18 PM
Viewing Multiple Related Records psudireddy Access 1 August 1st, 2006 11:07 PM
insert related records Haroldd Classic ASP Professional 2 April 15th, 2004 02:10 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.