INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Access Howto:

How do I add data to more than one Table by DougP
Posted: 24 Jun 00

this example shows how to add data to 3 tables at the same time using VBA code.
--------------------------
    Dim db As Database
    Dim rst1 As Recordset
    Dim rst2 As Recordset
    Dim rst3 As Recordset
    
    Set db = CurrentDb
    Set rst1 = db.OpenRecordset("Table1")
    Set rst2 = db.OpenRecordset("Table2")
    Set rst3 = db.OpenRecordset("Table3")
    
    rst1.AddNew
    rst1!Yourfield = Somedata   '<<<<<<< put data into table1
    rst1!Yourfield2 = Somedata2
    rst1.Update
    
    rst2.AddNew
    rst2!Yourfield = Somedata   '<<<<<<< put data into table2
    rst2!Yourfield2 = Somedata2
    rst2.Update

    rst3.AddNew
    rst3!Yourfield = Somedata   '<<<<<<< put data into table3
    rst3!Yourfield2 = Somedata2
    rst3.Update
    
    rst1.Close
    rst2.Close
    rst3.Close
    db.Close
-----------------------------------------

Back to Microsoft: Access Other topics FAQ Index
Back to Microsoft: Access Other topics Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close