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

Adding data to tables - Access 2000

Status
Not open for further replies.

allyeric

Programmer
Mar 14, 2000
104
CA
In my database, I have a form that allows user to create a new employee file.  The primary key is the employee number.  I have three other tables that I would like to create a new record for, only using the employee number, the rest of the record would be filled in at a later time.  Is there any way that when user enters the data to the form, that the employee number is also entered into the other three tables?  My form is created in VB6 using ADO.
 
You could create an &quot;Save Record&quot; button<br>It would save the record on the form and also add a new record to the other tables.<br>Like this:<br>---------------------------<br>Private Sub Command9_Click()<br>On Error GoTo Err_Command9_Click<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim db As Database, rst1, rst2, rst3 As Recordset<br>&nbsp;&nbsp;&nbsp;&nbsp;Set db = CurrentDb<br>&nbsp;&nbsp;&nbsp;&nbsp;Set rst1 = db.OpenRecordset(&quot;Table1&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;Set rst2 = db.OpenRecordset(&quot;Table2&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;Set rst3 = db.OpenRecordset(&quot;Table3&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;rst1.AddNew<br>&nbsp;&nbsp;&nbsp;&nbsp;rst2.AddNew<br>&nbsp;&nbsp;&nbsp;&nbsp;rst3.AddNew<br>&nbsp;&nbsp;&nbsp;&nbsp;rst1![employee number] = Me![employee number]<br>&nbsp;&nbsp;&nbsp;&nbsp;rst2![employee number] = Me![employee number]<br>&nbsp;&nbsp;&nbsp;&nbsp;rst3![employee number] = Me![employee number]<br>&nbsp;&nbsp;&nbsp;&nbsp;rst1.Update<br>&nbsp;&nbsp;&nbsp;&nbsp;rst2.Update<br>&nbsp;&nbsp;&nbsp;&nbsp;rst3.Update<br>&nbsp;&nbsp;&nbsp;&nbsp;db.Close<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>Exit_Command9_Click:<br>&nbsp;&nbsp;&nbsp;&nbsp;Exit Sub<br><br>Err_Command9_Click:<br>&nbsp;&nbsp;&nbsp;&nbsp;MsgBox Err.Description<br>&nbsp;&nbsp;&nbsp;&nbsp;Resume Exit_Command9_Click<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>End Sub<br>-----------------------------------<br><br>OK<br><br><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top