Solved

Insert data into multiple tables.

Posted on 2002-05-07
5
181 Views
Last Modified: 2010-05-02
can I use the SQL command to insert data into two tables together.  i have two tables A and B. I would live to insert data into field of both tables.  I have recorsets for each table inritistic(basic) data control, but dont know how to insert using data control properties.  I can insert into one table tough.
0
Comment
Question by:panesar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 4

Expert Comment

by:gencross
ID: 6995077
If you have two different recordsets, one for each, you can update the fields in the recordset

rs1.field("name").value = "First"
rs1.update

rs2.field("name2").value = "Last"
rs2.update

You can also create two different INSERT or UPDATE statements, one for each table.

INSERT INTO table1 (name) values('First')
INSERT INTO table2 (name2) values('Last')

UPDATE table1 SET name = 'First'
UPDATE table2 SET name2 = 'Last'

Hope this helps


0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 6995406
you can only INSERT into a singel table at a time.  It is not possible, with ONE insert statement. to insert data into two or more tables in the same SQL Statement.
0
 
LVL 3

Accepted Solution

by:
shyamkumarreddy earned 50 total points
ID: 6996177
Yeah You can do it Panesar
YOu have have to create a View of the 2 different tables into one view.
And with a single SQL statement you can insert into 2 different tables.

Shyam
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7722372
Hi panesar,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept shyamkumarreddy's comment(s) as an answer.

panesar, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:SpideyMod
ID: 7780138
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question