Adding data into two tables from single form through ADO

zonexs123

Registered User.
Local time
Today, 19:07
Joined
Feb 6, 2011
Messages
39
Hello Experts,

I am facing some problem while adding records into two tables from single form. I have used adodb.recordset to do so. However its work fine when its come to adding into single tables (example table: "Data1").

Table1: "Data1" contain following fields:
> Task
> User
> Address
> Phone

Table2: "Data2" cotain following fields:
> Task
> User

What I want that whenever I fill the details in form "Main_Form" its goes to table1 called "Data1" however I want to add similar field data (i.e. "Task" & "User") into table2 called "Data2".

I am using following code under "Submit" button:

Private Sub Command10_Click()
Dim rst As ADODB.Recordset
Dim strSql As String
strSql = "Select * from Data1"
Set rst = New ADODB.Recordset
rst.Open strSql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
rst.AddNew
With rst
!Task = Me.Text63.Value
!User = Me.Text53.Value
!Address = Me.Text1.Value
!Phone = Me.Text3.Value
End With
rst.Update
rst.Close
Set rst = Nothing
Text63.SetFocus
Text63.Text = ""
Text53.SetFocus
Text53.Text = ""
Text1.SetFocus
Text1.Text = ""
Text3.SetFocus
Text3.Text = ""
End Sub

Can anyone please help me out how should I add data into table2 "Data2" at same time when I am clicking "Submit" button.

I have also attached my database for your reference. Both the tables are vital to the functionality of other query or report. Hence, there is no any redundant data entry here.


Appericate your advise and solution......


Thanks in advance


With Regards,
Santosh
 

Attachments

Can anyone please help me out how should I add data into table2 "Data2" at same time when I am clicking "Submit" button.

At first glance, I do not see any code dealing with the second table.

I would think you would be successful simply duplicating your ADO code which does the INSERT upon the first table and also INSERT into the second table. Simply leave out the extra fields which the second table does not have.
 

Users who are viewing this thread

Back
Top Bottom