Cryptic, or post-copulatory, female choice could markedly affect the outcome of sperm competition, i.e. a female could differentially manipulate ejaculates within her own body, affecting the fertilization successes of her mating partners. Female yellow dung flies, Scathophaga (Scatophaga) stercoraria, have three spermathecae, the sperm-storage organs, and can to some extent store the sperm of different males in different places. I show that a female's body size, as well as those of her mates, influences the process of sperm storage. Furthermore, females lay eggs of different genotypes under different environmental conditions. Females use both cues correlated with single locus variation (at the locus for the enzyme phosphoglucomutase, PGM) and quantitative trait variation (in body size and development time) when using sperm to fertilize their eggs. It is proposed that this allows a female to match the genotypes of her offspring to the conditions in which the larvae must grow, thus increasing their subsequent fitness. I describe an experiment where larvae of different PGM genotypes were raised in different environments and the most successful genotype was different in different environments. The complexity of the female reproductive system may therefore have evolved because the best father for a female's offspring, from the female's viewpoint, is different under different environmental conditions. The effect interacts with the established male-determined effects to influence the outcome of sperm competition.