You must cast the spell kill the creature, you must also have the appropriate soul gem for the creature or person. You must kill them before the soul trap effect wears off.
Actually, I've run into this problem as well (I assume a bug). Have had empty Grand and Greater gems in my inventory, yet get the message: "no soul gem large enough" or w/e.