What is meant by the trust which Adam took upon himself, and when did that happen?
Question

When did Adam accept the trust? Was that before he ate the fruit? Or was it when he was on earth? Or do we not know about that?
Praise be to Allah.Allah, may He be exalted, says (interpretation of the meaning):
{Indeed, we offered the Trust to the heavens and the earth and the mountains, and they declined to bear it and feared it; but man [undertook to] bear it. Indeed, he was unjust and ignorant} [Al-Ahzab 33:72].
Ibn Jarir at-Tabari said in his Tafsir (20/337): the view that is most likely to be correct is the view of those who said that what is meant by the trust in this context is all types of trust in terms of religion, and trusts between people. That is because Allah did not specify any particular type of trusts when He said {we offered the Trust}. End quote.
Ibn Kathir said regarding the difference of opinions among the commentators of the earlier generations regarding the meaning of the trust: All these views do not contradict one another; rather they are agreed on tracing the meaning back to accountability and accepting the commands and prohibitions with their condition, which is that if man undertakes that he will be rewarded and if he neglects it he will be punished. And man accepted that despite his weakness, ignorance and wrongdoing, except those whom Allah helps and guides. And Allah is the one Whose help we seek.End quote from his Tafsir (3/522).
Secondly:
With regard to when Adam took on the trust, it is only narrated from Ibn ‘Abbas in his commentary on the verse (interpretation of the meaning):
{Indeed, we offered the Trust to the heavens and the earth and the mountains, and they declined to bear it and feared it; but man [undertook to] bear it. Indeed, he was unjust and ignorant}
[Al-Ahzab 33:72] that he said:
It was offered to Adam, and Allah said: Take it with all that it entails; if you obey you will be forgiven, and if you disobey I will punish you.
Adam said: I accept.
All it took was the time between ‘Asr and nightfall on that day, before he committed the sin. Narrated by at-Tabari (20/327).
Thus it becomes clear that Adam took on the trust when he was still in paradise, before he came down to earth and before he ate from the tree from which he had been forbidden to eat.
And Allah knows best.