Hi. You've probably got a problem with the disconnect motor on the front axle. It actuates a sleeve that locks the front axle shafts together. It has two vacuum lines to it, one for apply and one for release. Start the engine up and put it in four wheel drive. You'll have to go under the truck iwth it running, make sure its in park, wheels chocked, etc. You should see vacuum on one line, I think the left side. With it in two wheel drive the vacuum will be on the other hose. If you do have vacuum, you may have a problem with the disconnect itself, you would have to remove it from the axle housing to see if it slides. If it does slide, then you may have a problem in the transfer case.
If you don't have any vacuum to the disconnect, you may have a bad vacuum switch on the transfer case. Make sure the vacuum lines from the switch to the axle are good, make sure there is vacuum to the switch with the engine running. If you have no vacuum to the disconnect, lines are ok, and have vacuum at the switch on the transfer case, replace the switch.
Here is the diagram. Its kind of crude.