There is a Hadith in Sahih Bukhari which mentions that once Nabi (sallallahu ‘alayhi wasallam) fell off a horse and his leg or shoulder got injured after which he swore that he would not go to his wives for one month.
Why did the Nabi (sallallahu ‘alayhi wasallam) take that oath?
You are probably referring to the following Hadith:
Sayyiduna Anas (radiyallahu’anhu) reports that Rasulullah (sallallahu’alayhi wasallam) fell off his horse and injured his shin or shoulder. He (sallallahu’alayhi wasallam) [also once] took an oath that he will stay away from his wives for one month. [In both cases] He remained in an upper room of his, whose stairs were made from wood…
(Sahih Bukhari, Hadith: 378)
In this narration, Sayyiduna Anas (radiyallahu’anhu) was mentioning two separate incidents. The faling form the horse was not the cause for him (sallallahu ‘alayhi wasallam) taking the oath of abstention from his wives.
The falling off from the horse occurred in the year 5 A.H.
Whilst the incident of remaining away from his wives occurred in the year 9 A.H.
(Refer: Fathul Bari, Hadith: 689 and Taqrir Bukhari, part.2 pg.134)
And Allah Ta’ala knows best,
Answered by: Moulana Muhammad Abasoomar