G
Guest
I have 3 tables
table 1 is the main table that is populated from the main form
table 2 is populated from the sub form attached to the main form and info is
cleared once information has been transfered to table 3
I have coding to update table 1 using the main form and table 2 using the
sub-form when a submit button is clicked on the main. After all these tables
are updated a query is run to update table 3 so table 2 can be cleared.
However, the code I have tried to use to update column 1in table3 from
table1 doesnt work.
The feild is called BANo and it is the primary key which links table 1 and 3
together. I would like the number from BANo field in table 1 to be added into
BANo field in table 3 once the query to update table 3 from table2 has been
run.
the code I have tried to use is
Dim rs As DAO.Recordset
Dim kc As DAO.Recordset
Dim kct As DAO.Recordset
Dim ba
Set rs = CurrentDb.OpenRecordset("Table1")
Set kc = CurrentDb.OpenRecordset("Table3")
Set kct = CurrentDb.OpenRecordset("Table2")
ba = rs!BANo 'the ba is meant to store the BANo from Table 1
Do
If kct![Order] <>"" Then 'if the Order field in table 2 doesn't
= a number then
kc.addnew 'Add to table3
kc![BANo] = ba 'under the BANo field the BANo which is stored
in ba from table 1
Exit Do
End If
Loop Until kct![Order] = 0 ' stop the loop once there is no more numbers in
the Order field in table 2
I hope someone can help me with this
table 1 is the main table that is populated from the main form
table 2 is populated from the sub form attached to the main form and info is
cleared once information has been transfered to table 3
I have coding to update table 1 using the main form and table 2 using the
sub-form when a submit button is clicked on the main. After all these tables
are updated a query is run to update table 3 so table 2 can be cleared.
However, the code I have tried to use to update column 1in table3 from
table1 doesnt work.
The feild is called BANo and it is the primary key which links table 1 and 3
together. I would like the number from BANo field in table 1 to be added into
BANo field in table 3 once the query to update table 3 from table2 has been
run.
the code I have tried to use is
Dim rs As DAO.Recordset
Dim kc As DAO.Recordset
Dim kct As DAO.Recordset
Dim ba
Set rs = CurrentDb.OpenRecordset("Table1")
Set kc = CurrentDb.OpenRecordset("Table3")
Set kct = CurrentDb.OpenRecordset("Table2")
ba = rs!BANo 'the ba is meant to store the BANo from Table 1
Do
If kct![Order] <>"" Then 'if the Order field in table 2 doesn't
= a number then
kc.addnew 'Add to table3
kc![BANo] = ba 'under the BANo field the BANo which is stored
in ba from table 1
Exit Do
End If
Loop Until kct![Order] = 0 ' stop the loop once there is no more numbers in
the Order field in table 2
I hope someone can help me with this