If Moshe Rabbeinu was taught the entire Torah on Mt. Sinai (Rashi on Vayikra 25:1, Rambam), how do we explain events such as the incident involving the Bnos Tzelafchad (Bamidbar 27:1-11), or the tamei people who wanted to bring the Korban Pesach (Bamidbar 9:1-14), where Moshe evidently did not know the end of the story as recorded in the Torah?
The gemara in Sanhedrin 8a deals with bnos Tzelophchad. The first opinion holds that Moshe forgot the halacha as a punishment for when he appointed judges and said 'any law too hard for you, bring to me.' as if he were the final word and not Hashem. This is learned from the words Vayakreiv/Vatikr'vun.
The second opinion asks on this: Moshe didn't say (by the judges) I'll teach you, he says I'll listen to it (the difficult case, maybe he won't know it either and have to ask Hashem). This question in itself indicates that, at least according to this opinion, Moshe was not taught every nuance of halacha.
His answer also implies this: Moshe was worthy of writing the parasha (unlike opinion #1), but Bnos Tzelophchad merited to have it written through them (megalg'lin z'chus al y'dei zakay), so vayakrev es mishpatan.
It could be the 1st opinion also holds Moshe wasn't taught every nuance, but he darshans vayakrev/vatikr'vun. (efshar)
R. Ishmael said: The general directions were given at Sinai and the details in the Tent of Meeting. But R. Akiba said: The general directions and the details were given at Sinai and repeated in the Tent of Meeting and enjoined a third time in the Plains of Moab.
So according to R. Yishmael, we have an easy answer regarding the people who were impure and wanted to give the Korban Pesach. We can say that Moshe hadn't been taught that aspect of the law yet.
It would be a little more difficult to answer this about the Daughters of Tzelafchad though, since the story happened in the last year of the Jews being in the desert, and it would stand to reason that by then Moshe had been taught the whole Torah.
However, the Gemara (Baba Basra 119B) says that while Moshe had learned the laws, there was an extra aspect which Moshe was unsure of, and that was whether or not the daughters of Tzelafchad should get the extra portion that would have been due their father, since their father was a firstborn. (See here for an in depth explanation of this).
This explanation would seem to indicate that Moshe had not been taught every detail of the law, like R. Yishmael said.
Some other answers for why Moshe had to go to G-d to find out what to do with the daughters of Tzelafchad (This page was a good source):
The Shelah says that Moshe did know the law. However, once the daughters of Tzelafchad said that their father was not part of the rebellion of Korach, Moshe felt that this might be considered bribery. Since Korach was rebelling against Moshe's authority, by saying that their father didn't die because of Korach, they might have been trying to sway Moshe into giving a better judgement.
Once Moshe felt that, he recused himself and turned to G-d to judge the case. (see here)
The section relating to the laws of inheritance was intended to have been written at the instance of Moses our Teacher. The daughters of Zelophehad, however, were found worthy to have the section recorded on their account. Similarly, the law concerning the gathering of sticks on the Sabbath was to have been written at the instance of Moses our Teacher. The gatherer, however, was found culpable, and so it was recorded on his account. This is to teach us that evil is brought about through the agency of sinful men, and good through that of worthy men.
Bamidbar Rabba 21:12 brings that Moshe was punished for telling the judges "bring the hard cases to me and I will hear it" (which is a little arrogant I guess). G-d punished Moshe by having him forget a law and having it taught to him by the daughters of Tzelafchad (YDK brought this as well).
Bamidbar Rabba 21:13 brings that the law first came in front of judges of 10 who said that there are bigger, more Chashuv judges who can judge this, and the sent it to the judges of 50. The judges of 50 said the same thing and sent it up to the bigger judges, until it arrived to Moshe. Moshe saw that each of the judges had honored the judge greater than him and said that there is a Judge greater than me and went to ask G-d.