If the basic erase technique does not erase the image selected the image may be erase-protected. Check the image settings in the menu. If it is set to erase-protected, turn this setting off. See Canon EOS 40D Troubleshooting for more information on why your images cannot be erase.
Once no external flash is attached the built-in flash may not fire if the spring or metal switch in the hotshoe( the flash socket) that allows the flash to fire, is stuck. Dirt may be the cause of this. To fix it, clean the hotshoe with a soft brush or compressed air. If it still does not fire, unstick the spring with the help of a probe or pick. Slide the pick on the right side of the hotshoe to uplift the spring to its original position. See Canon EOS 40D Troubleshooting for more information.