It's in Numbrs 20. The story is rather odd. The Israelites are short of water in the wilderness and, as usual, start to grumble against Moses. So Moses and Aaron pray to God with the following result (Num. 20:6 - 8):
Then Moses and Aaron went from the presence of the assembly to the door of the tent of meeting, and fell on their faces. And the glory of the LORD appeared to them, and the LORD said to Moses, "Take the rod and assemble the congregation, you and Aaron your brother, and tell the rock before their eyes to yeald its water; so you shall bring water out of the rock for them; so you shall give drink to the congregation and their cattle."
Moses and Aaron respond as follows (Num. 20:9 - 11):
And Moses took the rod from before the LORD, as he commanded him. And Moses and Aaron gaathered the assembly together before the rock, and he said to them, "Hear now, you rebels; shall we bring forth water for you out of this rock?" And Moses lifted up his hand and struck the rock twice; and water came forth abundantly, and the congregation drank, and their cattle.
So far, we have a pretty straight-forward miracle story. Then it gets weird (Num. 20:12):
And the LORD said to Moses and Aaron, "Because you did not beleive in me, to sanctify me in the eyes of the people of Israel, therefore you shall not bring this assembly into the land which I have given them."
This is one of those head-scratching passages in the Bible, where things don't make any sort of sense. Moses and Aaron seem to have done what God asked them to do. Yet, for this one infraction (whatever it was) he denies them entry into the Promised Land. There are generally two explanations for God penalizing the two men for doing what he told them to do. One is that Moses says, "Shall WE bring forth water for you out of this rock?" meaning that he was claiming to be the power behind the miracle. The other is that he struck the rock twice, indicating that he wasn't trusting in God, in which case he would have struck it once. Both explanations seem rather lame.
The problem is complicated further when Moses says in his farewell speech to the people of Israel, in Deurteronomy, that he asked God if he could go across the Jordan to see the Promised land (Deut. 3:26, 27):
But the LORD was angry with me on your account, and would not hearken to me; and the LORD said to me, "Let it suffice you; speak no more to me on this matter. Go up to the top of Pisgah, and lift up your eyes westward, northward, southwrd and eastward, and behold it with your eyes; for you shall not go over this Jordan."
So here, in a rival document (D) Moses isn't being punished for any lapse on his part, but is, rather unjustly, punished for the sins of his people.