A few things you might try:
1) Buy some Hogue grips. They're cheap and make recoil absorption into the hand much smoother, so you're less likely to flinch. I love them on my P226.
2) Try the 9mm barrel, spring, and mags in your .40 P229. Then you can be 100% confident it's not a difference in the gun.
3) Remember consciously, the bullet is long gone by the time you feel and can react to recoil, so trying to compensate for accuracy is pointless. I know this is a hard one and I continue to struggle with it