If the problem only occurs when you're away, it may be related to separation anxiety or you may be leaving her alone for longer than she can control her bladder or bowels. Ask your veterinarian for guidance or for a referral to a trainer. If you're starting with a new dog regardless of age, the basics are the same. Most dogs naturally want to keep their dens clean. Some dogs catch on quickly.
Some dogs have to be taught room by room.
Dogs who are allowed to sleep in your bedroom often adopt the bedroom as part of the den very easily. Just because she can go all night without messing in the bedroom, doesn't mean she's house trained. Teach her what you want one room at a time. Give her food and water on a regular schedule. Remove her water ten minutes after you remove her food.