All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
We have not come across in any religious books that a person prayed 40 days with one ablution. A human being cannot avoid sleeping and relieving himself for this long a period, and all these matters invalidate ablution. If it is proven that a person was an exception to this universal fact, then this is a super natural matter, and Allaah is capable of everything.
However, in the history and biography books, we have come across that Abu Haneefah performed the Fajr prayer with the ablution of the 'Ishaa' prayer for 40 years. This means that he prayed at night with the ablution of 'Ishaa' until he performed the Fajr prayer. It is also reported about him that he performed the five daily prayers for a period of 45 years with one ablution; as was reported by Al-Khateeb Al-Baghdaadi . The same thing was said about Yazeed Ibn Haaroon and other devout worshippers.
It is also said that Ibraaheem Ibn Adham performed 15 prayers with one ablution; if these prayers were all obligatory prayers, this means that he performed the prayers for three days with one ablution. But we have not come across any source that one person performed the prayers of 40 days with one ablution.
Allaah Knows best.