How many miles on the car? What year?
If the car has a lot of miles on it, it might be time for a rebuild. However, you may be able to lesson the erratic shifting by having the trans fluid flushed, depending the condition of the current fluid.
I don't know much about volvo's, but if there is a dip stick for the trans, check it. What color is the fluid? Should be a redish pink, if its dark, or black, then get the trans flushed. Should help.
If the trans fluid color is good, and is not low, then I suggest you bring it to a transmission shop to have them diagnose the problem. It is too hard to do so over the internet. You might have better luck on the Volvo forums.