Adding rows via a form to two tables

A

aine_canby

Hi,

I wish to produce a form which refers to info in a particular table.
The table is called Test. The thing is, I also have a second table
called TestVersion. TestVerson has a field containing the ID of a row
in the Test table. Each test has one or more version. So, for my Test
form, I wish to also create a new entry in the Test Version table
(version 1) each time I add a new test - as well as the Test entry.

What is the best way to do this?

Thanks,

Aine.
 
P

Pieter Wijnen

Private Sub Form_AfterInsert()
Dim Db As DAO.Database
Set Db = Access.CurrentDB()
Db.Execute "INSERT INTO TestVersion (TestID, Version)" & VBA.vbCrlf & _
"VALUES (" & Me.TestID.Value & ",1)" DAO.dbSeeChanges +
DAO.dbFailOnError
Set Db = Nothing
End Sub

HTH

Pieter
 
Top