Dogs determine where their bathroom is located by odor. If there has been a dog in the area before, he will go where he smells the odor of urine. If he becomes uncomfortable, he will design a new restroom for himself right on the spot without the smell. I suspect what took place on the beds was he was feeling discomfort.
Try to take him outside every few hours for a while even if you have to get up at night. When he picks a spot outside, take him back to that spot. As he gets into the routine, gradually extend the time period. If you see him go to the door, make sure he gets to go out so he will learn to let you know when it's time.
Yorkies are emotional and sensitive so they're a lot harder to potty train than some other breeds. You will need some patience.