I have a database that has one parent table and multiple child tables. The parent table has a RecordID field (primary key) that is an AutoNumber. All the child tables have RecordID field with a one-many relationship to the parent RecordID field.
What I am attempting to do is have the RecordID in all of the Children automatically populate with the parents RecordID upon entry into the Parent table. I've been trying to use VBA to generate a SQL Insert Into statement, but have not had luck getting it to work. Here is my SQL statement:
Dim sql As String
sql = "Insert into CentralAir (CA-RecordID) Values ('" & Me.RecordID & "');"
DoCmd.RunSQL sql
I have the SQL statement in an OnClick event prior to an update routine. Perhaps I'm making this to hard and the is an easier solution.
Thanks for any help/advise
MK
What I am attempting to do is have the RecordID in all of the Children automatically populate with the parents RecordID upon entry into the Parent table. I've been trying to use VBA to generate a SQL Insert Into statement, but have not had luck getting it to work. Here is my SQL statement:
Dim sql As String
sql = "Insert into CentralAir (CA-RecordID) Values ('" & Me.RecordID & "');"
DoCmd.RunSQL sql
I have the SQL statement in an OnClick event prior to an update routine. Perhaps I'm making this to hard and the is an easier solution.
Thanks for any help/advise
MK