Hi,
THere are seven tables linked to each other by primary key. I have an Unbound form with an one unbound textbox and one bound textbox , users enter values in the unbound Textbox so . the Values entered in the unbound textbox should be added to all the seven tables . I used this code to add values in all the tables without a hitch. But I need to add values only in those tables when bound textbox value is equal to primary key value in the tables.
Code to add values in unbound textbox to the tables. ( Code pasted here is the code i am testing with two sample linked with pimary key " cust_id " and "id")
Dim dbs As Database
Dim rst As Recordset
Dim qst As Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tbl_customer", dbOpenTable, dbAppendOnly)
Set qst = dbs.OpenRecordset("tbl_Providers", dbOpenTable, dbAppendOnly)
With rst
.AddNew
!cust_id = Me.frm_test
.Update
End With
rst.Close
With qst
.AddNew
!id = Me.frm_test
.Update
End With
qst.Close
Set dbs = Nothing
THere are seven tables linked to each other by primary key. I have an Unbound form with an one unbound textbox and one bound textbox , users enter values in the unbound Textbox so . the Values entered in the unbound textbox should be added to all the seven tables . I used this code to add values in all the tables without a hitch. But I need to add values only in those tables when bound textbox value is equal to primary key value in the tables.
Code to add values in unbound textbox to the tables. ( Code pasted here is the code i am testing with two sample linked with pimary key " cust_id " and "id")
Dim dbs As Database
Dim rst As Recordset
Dim qst As Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tbl_customer", dbOpenTable, dbAppendOnly)
Set qst = dbs.OpenRecordset("tbl_Providers", dbOpenTable, dbAppendOnly)
With rst
.AddNew
!cust_id = Me.frm_test
.Update
End With
rst.Close
With qst
.AddNew
!id = Me.frm_test
.Update
End With
qst.Close
Set dbs = Nothing
Last edited: