Action following database query not working

Thanks @Dean Pitout