Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cascading fields into multiple tables

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Is there a method in Access that allows a field to be cascaded into multiple tables during input. For example, if I have an eventID# that I would like to input just once in a form and then have that field be entered in multiple tables?
 
one, not so sophisticated way, is to have an Append Query associated with the AfterUpdate property of the eventID# of the field. But this will give you many Key violation errors (if eventID#) is your key field. these errors are relatively harmless, they are just informing you that you cannot replace a record that is already there. if you write the event procedure that rund these queries in VB you can actually pretty much eliminate the messages, or make them something friendlier.<br>
<br>
or, you can write the code that automatically inserts into said other tables in the AfterUpdate property. <br>
<br>
<p>Brian Famous<br><a href=mailto:bfamous@ncdoi.net>bfamous@ncdoi.net</a><br><a href= > </a><br>
 
This code will add records to 3 tables<br>
<br>
Dim db As Database, rst, rst2, rst3 As Recordset<br>
Set db = CurrentDb<br>
<br>
Set rst = db.OpenRecordset(&quot;MyTable&quot;)<br>
Set rst2 = db.OpenRecordset(&quot;MyTable2&quot;)<br>
Set rst3 = db.OpenRecordset(&quot;MyTable3&quot;)<br>
<br>
rst.AddNew<br>
rst.Fields(&quot;MyField&quot;) = Me!Text1<br>
rst.Fields(&quot;MyField2&quot;) = Me!Text2<br>
rst.Update<br>
<br>
rst2.AddNew<br>
rst2.Fields(&quot;MyField&quot;) = Me!Text1<br>
rst2.Fields(&quot;MyField2&quot;) = Me!Text2<br>
rst2.Update<br>
<br>
rst3.AddNew<br>
rst3.Fields(&quot;MyField&quot;) = Me!Text1<br>
rst3.Fields(&quot;MyField2&quot;) = Me!Text2<br>
rst3.Update<br>
<br>
rst.Close<br>
rst2.Close<br>
rst3.Close<br>
db.Close<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top