1. Heat the oven to 350 degrees F.
2. Liberally grease the bottom and sides of a 9x13-inch baking dish or casserole.
3. Place one-third of sliced potatoes in bottom of casserole and dot with 2 tablespoons of butter. Spread 7 slices of ham, 5 slices of cheese, and half the onions on top of potatoes. Sprinkle with 2 tablespoons of flour and salt and pepper.
4. Repeat layering but reserve half of the potatoes and 4 slices of cheese.
5. For last layer, add remaining potatoes and cheese. Salt to taste.
6. Pour milk over layers. Cover baking dish loosely with foil.
7. Bake until potatoes are tender, about 1-½ hours. Remove foil after 40 minutes.