PC Review


Reply
Thread Tools Rate Thread

Add three new records

 
 
HelpMe!
Guest
Posts: n/a
 
      5th Jan 2010
When i add a new record to my "EmployeeInfo" table, the "EmployeeID" field
adds a new autonumber. I would like to create a macro that, when i push my
"Add a New Employee" button, also adds the new "EmployeeID" to my "Probation"
table three times. Each time, i would also like the macro to enter a
different number in the "Period" field.

Example of Probation table after Macro:

EmployeeID Period
2233 1
2233 2
2233 3



 
Reply With Quote
 
 
 
 
Steve Schapel
Guest
Posts: n/a
 
      5th Jan 2010
HelpMe,

1. Make a new simple table (let's call it ProbabtionPeriods) with 1
Number/Integer field [Period] and 3 records: 1, 2, 3.

2. Make a query (let's call it NoProbabtion) to return the EmployeeID where
there are no related Probation records. The SQL view of such a query will
look something like this:
SELECT EmployeeInfo.EmployeeID
FROM EmployeeInfo LEFT JOIN Probation ON EmployeeInfo.EmployeeID =
Probation.EmployeeID
WHERE Probation.EmployeeID Is Null

3. Make another query, based on the table from point 1 above, and the query
from point 2 above. Make this into an Append Query to write the records to
the Probation table. The SQL view of such a query will look like this...
INSERT INTO Probation ( EmployeeID, Period )
SELECT NoProbabtion.EmployeeID, ProbationPeriods.Period
FROM NoProbation, ProbationPeriods

4. Add an OpenQuery action to your macro, to run the append query from
point 3 above.

--
Steve Schapel, Microsoft Access MVP


"HelpMe!" <(E-Mail Removed)> wrote in message
news:16FE945C-97B0-44E6-BF54-(E-Mail Removed)...
> When i add a new record to my "EmployeeInfo" table, the "EmployeeID" field
> adds a new autonumber. I would like to create a macro that, when i push my
> "Add a New Employee" button, also adds the new "EmployeeID" to my
> "Probation"
> table three times. Each time, i would also like the macro to enter a
> different number in the "Period" field.
>
> Example of Probation table after Macro:
>
> EmployeeID Period
> 2233 1
> 2233 2
> 2233 3
>
>
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieve records, and all records joined to those records, etc., e Peter Stone Microsoft Access Queries 2 12th Jun 2009 05:41 AM
How to Form/Subform automatically duplicate records everytime I update records. ylho Microsoft Access Forms 0 6th Jun 2006 11:48 PM
to Duane Hookom - how to use Pivot Charts for individual records instead of summing all records Harold Good Microsoft Access Reports 1 21st Dec 2005 06:26 PM
Nslookup query for NS records returns all of the NS records, but not all of the Host records Bob Microsoft Windows 2000 Networking 1 8th Nov 2004 07:03 PM
Nslookup query for NS records returns all of the NS records, but not all of the Host records Bob Microsoft Windows 2000 DNS 2 7th Nov 2004 04:42 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:37 AM.