Question

Parent (licenseID, countChilds)
Child (hostID, licenseID)

Trying to write an after insert/update/delete trigger that fires when adding a record to the child table. It needs to count child records linked to the parent and then insert this value into the parent.

But I keep getting the SQL statement is not valid.

So far I have this: enter image description here

I am using MS Access 2010.

Was it helpful?

Solution

I am fairly sure you can get away with DCount, for example, this works for me:

data macro

But I would still recommend not doing this and just getting your counts from a query.

OTHER TIPS

This seems to work, at least for After Insert:

AfterInsert.png

The After Update Data Macro would be a bit more involved because it might have to update two [License] records (one for [Host].[licenseID] and another for [Old].[licenseID]), or perhaps none (if [Host].[licenseID] did not change).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top