When I turned on the power after I originally hooked up the switch it was set to on and I thought everything was fine, then I turned it off and the breaker went off. So, I switched the black and white wires on the switch and turned the breaker back on and the light worked and when I turned it off, the breaker went again. The old heat fan that was there ha2 2 sets of romex going to it. One set went to a plug and the other went to another plug and those plugs connected together to give the fan power. One of the romex goes to the switch and I think the other one goes to a vanity light that's in there, but I'm not sure. I put the 2 blacks and connected them to the black and red from the lamp and the 2 whites and connected them to the white from the lamp. Are you saying that one of the whites should have gone to the blacks and red?You have miswired a switch loop. You are actually turning on the switch. Did you "fix" a problem when you found a white connected a bunch of blacks at the fixture? It is supposed to be connected to the blacks.
http://www.diychatroom.com/f98/how-attach-photo-post-20532/I tried to insert a drawing, but it didn't work.
I repeat.Tell us about the wires on the switch as well. Which cable has the red? The one to the switch or the one to the vanity.
If you can tell then why are you asking. However I am led to believe that the first sentence is false and that you must do voltage measurements.I can reach my hand up in the ceiling and tell which piece of romex is going to the switch and which is going elsewhere. Will that tell me which wires go where?