Arrange a layer of potatoes in the bottom of a well buttered oven proof dish.
Sprinkle with chopped onion and season with salt & pepper.
Cover with a layer of chopped ham, then a layer of grated cheese.
Repeat twice more finishing with a thick layer of grated cheese.
Pour the beaten egg and milk over the contents of the dish.
Cover with a sheet of greaseproof paper and cook at 350 degrees F (180 degrees C) or Gas mark 4 for 1.25 to 1.5 hours until the potatoes are tender.
Remove the greaseproof paper and continue cooking until the top is nicely browned.