We got our Shih Tzu, who passed away at 16, when she was two months old. When she got to our condominium at the time, we let her walk around a little bit and made sure she knew each room. After that was over, we took her outside for long walk and then she came back in ate, drank water, walked around more and then a few hours later we took her outside.
Eventually it became routine. She didn't really have any accidents when she was younger, but when she got older (I'd say at around 10) she started to have them, which wasn't a big deal to us at the time because we, as well as the vet, understood it happens at older ages.
No matter how many times we took her our, which she hated when she got older, she would piss on the floor when she got back from her walk.