papadega3000
Registered User.
- Local time
- Today, 16:09
- Joined
- Jun 21, 2007
- Messages
- 80
Hello,
I am trying to make a form that will enter data in 3 different tables. I created a tabbed form with 3 pages. Each page corresponding to a separate table.
In Design view I set the Form Record Source to include the three tables I want to enter data to and set it to data entry = yes.
I added a submit button that would execute the following VBA code:
Private sub Submit_Click()
'inserts into Table1
CurrentDb.Execute "INSERT INTO Table1(field1,field2,field3,field4,field5,field6) VALUES ('" & field1.Value & "','" & field2.Value & "','" & field3.Value & "','" & field4.Value & "','" & field5.Value & "','" & field6.Value & "')"
' inserts into Table2
CurrentDb.Execute "INSERT INTO Table2(field1,field2,field3,field4,field5,field6) VALUES ('" & field1.Value & "','" & field2.Value & "','" & field3.Value & "','" & field4.Value & "','" & field5.Value & "','" & field6.Value & "')"
inserts into Table3
CurrentDb.Execute "INSERT INTO Table3(field1,field2,field3,field4,field5,field6) VALUES ('" & field1.Value & "','" & field2.Value & "','" & field3.Value & "','" & field4.Value & "','" & field5.Value & "','" & field6.Value & "')"
End Sub
Now when I execute the code two issues occur:
1. I can enter text into the first page but the other pages don't let me enter text in the boxes.
2. I get a run-time error on each line of code saying " Run-time error 424 - Object Required"
However the data entered into the first page shows up in the table after I re-open it.
I would appreciate any help I can get I would like to solve this problem as soon as possible.
I am trying to make a form that will enter data in 3 different tables. I created a tabbed form with 3 pages. Each page corresponding to a separate table.
In Design view I set the Form Record Source to include the three tables I want to enter data to and set it to data entry = yes.
I added a submit button that would execute the following VBA code:
Private sub Submit_Click()
'inserts into Table1
CurrentDb.Execute "INSERT INTO Table1(field1,field2,field3,field4,field5,field6) VALUES ('" & field1.Value & "','" & field2.Value & "','" & field3.Value & "','" & field4.Value & "','" & field5.Value & "','" & field6.Value & "')"
' inserts into Table2
CurrentDb.Execute "INSERT INTO Table2(field1,field2,field3,field4,field5,field6) VALUES ('" & field1.Value & "','" & field2.Value & "','" & field3.Value & "','" & field4.Value & "','" & field5.Value & "','" & field6.Value & "')"
inserts into Table3
CurrentDb.Execute "INSERT INTO Table3(field1,field2,field3,field4,field5,field6) VALUES ('" & field1.Value & "','" & field2.Value & "','" & field3.Value & "','" & field4.Value & "','" & field5.Value & "','" & field6.Value & "')"
End Sub
Now when I execute the code two issues occur:
1. I can enter text into the first page but the other pages don't let me enter text in the boxes.
2. I get a run-time error on each line of code saying " Run-time error 424 - Object Required"
However the data entered into the first page shows up in the table after I re-open it.
I would appreciate any help I can get I would like to solve this problem as soon as possible.