View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Little Penny[_4_] Little Penny[_4_] is offline
external usenet poster
 
Posts: 13
Default Update to Access Multiple tables via VBA



I'm somewhat familiar with updating from Excel to Access via VBA. How
can I update to multiple tables in Access that have a one to many
relationship using VBA. Table are linked via key.

tbl_One is one Many with tbl_Two via Foreign Key
tbl_One is one Many with tbl_Three via Foreign Key


Set db = OpenDatabase("C:\LinkedTest\LinkTestDB.mdb")

' open the database
Set rs = db.OpenRecordset("tbl_One", dbOpenTable)

With rs

..AddNew ' create a new record
' add values to each field in the record
.Fields("TableFieldName2") = Range("A1").Value
.Fields("TableFieldName2") = Range("B1").Value
.Fields("TableFieldName2") = Range("C1").Value

Here I what to updated data to tbl_Two which linked to tbl_One

Here I what to updated data to tbl_Three which linked to tbl_One


.Update ' stores the new record
End With


Thanks


Little Penny