Flies are best controlled when their food source/ breeding material is removed.
When removal of fly breeding materials is not possible, the use of baits, sprays and traps can be incorporated in a fly management program.
For small flies (drain flies, moth flies, indoor gnats) in the home or kitchen, removal of the thin layes of scum in drains is very important.  Use Invade Bio Drain Gel for the job. 
When larger flies rest or land on surfaces such as exterior walls, dumpsters and other objects the use of an insecticide spray if often needed.   Wettable powders such as Cyper WP give the best knock-down and longest residual.  
Ultraviolet fly traps are powerful tools that work continuously, luring flies to the trap with the power of special UV rays designed for controlling flies.