I see.That code is only for newly spawned pokemon; I have no idea how to edit already existing pokemon. Do be aware that you are effectively EV-training all wild pokemon when you use the code, so they will be accordingly harder to beat.
I also have no idea if the game will let you bypass the 510 EV limit; I never tried to do it, as it would result in illegal pokemon and I want to keep my own pokemon legal(ish).
Well, I tested it on Violet and didnt work
And it didnt affect pokemons from trainers, gyms & etc, right?