When flies become a problem, you can buy pesticides or commercial fly traps to get rid of them; however, it's easier, cheaper, and just as effective to make your own fly trap. You'll keep the dangerous chemicals away from your family and pets and recycle a glass jam or peanut butter jar at the same time.
Combine the sugar and vinegar in the glass jar. Add 1/4 cup of water. Put the lid on the jar and twist it until it is secure.
Shake the contents until the sugar dissolves. Remove the lid.
Add enough water to fill the jar halfway full.
Pound the nail through the lid to make several (five to seven) evenly spaced holes in the lid. Each hole should be large enough to allow a fly to enter the jar through the holes. A housefly trap will require much larger holes than a trap intended to capture fruit flies.
Screw the lid back on the jar. Flies will be attracted by the scent of the vinegar solution and will go into the jar but will not be able to get out.