How to create a trigger to update another table?

S

subzizo

Hi All ,How can i create something like a trigger or procedure when i insert
a record in a table it updates a specific field of its parent record in the
parent table?
 
S

Steve Schapel

Subzizo,

You could use the BeforeUpdate event of the form. Here is an example of
one possible approach (untested air code!)...
If Me.NewRecord Then
CurrentDb.Execute "UPDATE ParentTable SET SpecificField = Something
WHERE TheID=" & Me.ID, dbFailOnError
End If
 
S

subzizo

Dear Steve thank you for reply i tried your code but it gives me error i made
some changes to be as follow


If Me.NewRecord Then
SQL1 = "update events set coverage='Yes' where event_id = " & Me.event_id
CurrentDb.Execute SQL1, dbFailOnError

End If

it doesn't raise errors but also the update process didn't work

thank you
 
S

Steve Schapel

Subzizo,

What is the data type of the Coverage field? If it is a Yes/No data
type, then the ''s are not correct.
 
Top