Automatic update lookups

Automatic update lookups

I have Form A with a lookup field to Form B. This look up field retrieves the value from Form B and fetches corresponding data from that report. 

The fetched data is only accurate at the time of user input in the lookup field - if Report B changes; then the data is now out of date. I have written the following function to update the records in Report A to capture any changes but this has to be executed manually;

void Update_category()
{
for each  rec in Register_vehicle[Category != ""]
{
var = Vehicle_database[ID == rec.ModelLook];
rec.Category=var.Category;
}
}

So my question is; how can I automate this process so that the function is always run without manual execution.


Thanks,

Sean