2002 Volvo hesitation in shifting

I have a 2002 Volvo S40 1.9T automatic with 47,000 mi. Occasionally when it has been sitting in hot outside temperatures for a few hours, it has a strange problem when I first start to drive. For the first mile or two, when it needs to up shift from 3rd to 4th, it will shift out of 3rd but not catch 4th for a second or two - the engine revs go way up but the car is coasting. Eventually it catches with a jerk and is OK, and this stops once it has been driven for a while. But just to make it more complicated, every once in a while it can do the same thing in cool weather or after it has been driven for several miles. The dealership says there is nothing wrong with it although I have complained about it every summer since I bought it from them in 2003 with 13,000 mi on it. Any ideas?