It definetly prevents gas and works with foods as you eat them. Beano doesn't help for taking once you already have gas. For trapped gas I find Gas-X works best.
The beano website explains everything about how it works and lists of foods that can cause gas: http://www.beanogas.com/
Hope this helps, and dont be afraid to try other gas products that people have mentioned.