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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy recordset to several other tables

Status
Not open for further replies.

video32a

IS-IT--Management
Apr 24, 2000
28
US
I have several forms that I would like to filter from one primary and several linked tables. however I need to copy the original primary key to these other tables secondary key behind the scenes (from my original to several other forms). Thank in advance for your help.<br>Charlie<br>
 
I'm sorry but I don't understand the question.&nbsp;&nbsp;I'm not sure what you mean by &quot;I have several forms that I would like to filter from one primary and several linked tables.&quot;<br><br>Do you mean that you have several forms based on queries that reference these tables?<br><br>Do you want to update tables based on entries into these forms?<br><br>I'd love to help if I can.&nbsp;&nbsp;It often helps if you use real names; something like<br><br>I have three tables, tbl1 with PK of ID, tbl2 with PK of XNumber and FK of ID, etc.<br><br>Kathryn
 
Kathryn,<br>Thank you for your help. I am trying to copy tbl1 pk of id to tbl2&nbsp;&nbsp;pk of x number and tbl3 fk of id. I would like like to do it in memory maybe with DAO after entering tbl1 pk of id in a text box, maybe by clicking on a button, then drop it automatically into the other tables. I know how to do it with a notinlist property on a combo box but not on text box.<br>Startup form with tbl1<br>form2 form with tbl2<br>form3 form with tbl3<br><br>When queried id matches all forms (that part is no problem) it is the firing a record into the tbl2 and tbl3 while their forms are closed<br>Thanks in advance<br><br>
 
OK, let me make sure I have this correct.<br><br>You have three tables.&nbsp;&nbsp;When you choose data from tbl1 using a form you want to have the data (all of it??) entered into two other tables.&nbsp;&nbsp;For this you need recordsets.<br><br>Call the startup form frmStartup.&nbsp;&nbsp;Say it has one combobox, call it cboID, with a bound column of ID, and two textboxes, txt1 and txt2.&nbsp;&nbsp;(This is what I meant in my previous post about using names.&nbsp;&nbsp;It makes it easier to discuss things.)<br><br>When you choose a value from cboID, you want the corresponding values of txt1 and txt2 to be put into tbl2 and tbl3.<br><br>The code would look like this and would probably go into your cboID_AfterUpdate() procedure.<br><br>This is very rough, but it should get you started.<br><br>***Start of Code***<br>dim rst2 as recordset<br>dim rst3 as recordset<br>dim strTxt1 as string<br>dim strTxt2 as string<br><br>strtxt1 = me!txt1<br>strtxt2 = me!txt2<br><br>set rst2&nbsp;&nbsp;= currentdb.openrecordset(&quot;tbl2&quot;)<br>set rst3 = currentdb.openrecordset(&quot;tbl3&quot;)<br><br>rst2.addnew<br>rst2!fieldname1 = strtxt1<br>rst2!fieldname2 = strtxt2<br>rst2.update<br><br>rst3.addnew<br>rst3!fieldname1 = strtxt1<br>rst3!fieldname2 = strtxt2<br>rst3.update<br><br>rst2.close<br>rst3.close<br>***End of Code***<br><br>Let me know if you need more help, or if I did not understand your problem correctly.<br><br>Kathryn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top