A non-transitory computer-readable storage medium having stored therein a program for causing a computer to execute a method of controlling an image forming apparatus for forming an image designated by a job on a sheet fed from one of a plurality of paper feed sources, the method comprising:
- holding paper sizes and paper types that are set by the user in one-to-one correspondence with the plurality of paper feed sources;
- detecting paper types of sheets respectively fed from the plurality of paper feed sources when the sheets are conveyed, the detecting being performed on a conveyance path used in common for the fed sheets;
- holding the paper types detected in the detecting in one-to-one correspondence with the plurality of paper feed sources;
- holding a paper size designated by the job and a paper type designated by the job or a condition related to setting of a paper type;
- selecting, when the paper size and the paper type designated by the job are held, from among the plurality of paper feed sources, a paper feed source loaded with sheets having the paper size and the paper type designated by the job with reference to information set by the user;
- selecting, when the condition is held, from among the plurality of paper feed sources, a paper feed source that satisfies the condition with reference to information set by at least one of the user and the paper types detecting in the detecting;
- and
- performing control to feed a sheet from the paper feed source selected with reference to the information set by the user or the paper types detected in the detecting and form the image designated by the job thereon.