Four wheel drive problem

I have a 1998 Ford F150 with automatic transmission. When I move the selector switch from 2H to 4H while traveling at the proper speed (above 5 mph and less than 50 mph) the 4x4 indicator lamp lights up but the truck does not go into 4 wheel drive. When I stop the truck and put the trans in park or neutral and move the switch to 4L the indicator lamp lights up and the truck drops into low range but does not go into 4 wheel drive.