A Muslim may work and comply with all of the things (we just mentioned) and ask Allaah for success and assistance. However, what occurs may be something other than what you intended. So you must know that this is part of Allaah's Divine Decree which He has allowed to occur. Just look at the son of the messenger of Allaah, Nooh, and at how he wasn't righteous. And look at the wife of Loot who also wasn't righteous, as well as the wife of Nooh, even though they were married to prophets of Allaah.
"And Nooh called upon his Lord and said: 'O my Lord, verily my son is of my family! And certainly Your promise is true, and You are the most just of judges. He said: 'O Nooh! Surely, he is not of your family. Verily, it is an act that is dishonorable. So do not ask Me about that of which you have no knowledge. I admonish you lest you should be one of the ignorant.' Nooh said: 'O my Lord! I seek refuge in you from asking You about that which I have no knowledge of. And unless You forgive me and have mercy on me, I would indeed be one of the losers.'" [Surah Hood: 45-47]
So a Muslim must work and abide by the lawful means. And everyone will be facilitated towards the purpose for which he was created.
O Allaah, make us of those who guide others and of those who are guided, not of those who are astray or leading others astray. O Allaah, send Your peace and praises upon Muhammad, his family and Companions.