When you have done this in the past did you return to him while he was whining? If so you probably inadvertently reinforced the behavior (he whines, you come back so his whining "worked".)
I had a similar problem with my terrier mix, he would bark his head off whenever I walked away from him, although in his case he only would continue as long as he could see me and if he saw me leave. If I could get someone to distract him and then get out of his sight before he noticed me walking away, he would stay perfectly quiet. So in his case it was more of an issue with him actually seeing me leave. But anyway someone suggested I wait him out: to avoid reinforcing him for barking by coming back while he was barking, they suggested I not return until he stopped. Unfortunately my dog was a tenacious terrier and it was difficult to wait him out. However that might be an option for your dog if you can wait out the barking, and then return and reinforce him when he is quiet.
Another thing that might help is to practice walking away and then returning quickly before he has a chance to start whining, then slowly build up the time you leave so he will realize you are going to be coming back (plus it gives a lot of opportunities to reinforce him for not whining.)
For example the first time you might just walk away and then turn around and immediately walk back without leaving. The next time you might go through a doorway and then walk right back to him, and then after practicing that a few more times you might walk through a doorway and then pause for a few seconds before walking back, and so on.
If you do this and at any point he starts whining/barking while you're practicing this, go back a step (so for example if you walked to the doorway and he is whining, you might go back to practicing walking only halfway across the room for a little while and then try increasing the distance again.)
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Jubal/Tesla (Beauceron) 3/14/14
Bianca HIC CGC TT (GSD) 4/24/04-10/23/12