How old is this dog, what breed and for how long have you had him? All that information would help me to help you. Best I can offer is if he is older, you go back to puppy one. Take him out to empty immediately he wakes from a nap, after every feed and short periods of playing, if relevant (puppy). In other words, limit the opportunities he has to mess indoors. Have you used pee pads because you are now facing untraining him (from messing indoors) and properly training.
When you take (go with him) him outside to do what he needs to do out there, don't keep him out for much over 5 minutes or he'll just find something out there of interest - forget about peeing/poohing. If he doesn't empty when you KNOW he needs to, bring him back indoors, but instead of letting him have the run of the house again, keep him by the door to the outside, stay with him and the moment he goes to squat, say NO! and take him straight back outside. Don't shout or hit - he'll just run which is the last thing you want to happen.
Be persistent, consistent - praise when he does go outside, correct ONLY in the act, and clean up the mistakes without comment. Eventually, assuming this isn't a medical problem, he will get the message.