Can anyone help me to define the function(s) that will help me to write this code?
I have a form that can be accessed from three different sources of the application.
When the form (X) is about to be opened, I want to store the form name of the form that control is being transferred from.
When the form (X) is closed, I want to return to the form that initially transferred control to (X). Thanks.
Well, the simplest thing would be to leave the previous form open underneath this form. Otherwise, you could use OpenArgs to pass the name of the form calling the second form, and use that to open the form back up as the second form closes.
The best way is what pbaldy mentioned, by making your form invisible and then visible you do it faster and without need to close and reload the form which takes time and memory, anyhow if you want to close the form then you can declare a public string variable in General Declaration section of one of your modules ( it only works in module level ) and store the first form name on close event in the string variable and use it when closing the second form to open the first form again, this method is good when you have several buttons and each open a form and you want by closing the available form the previous form to be opened.
<<Never Walk on the Traveled Path, Because it only Leads you to where the Others have been.>>
Form A. Open form B (stores Form A in your global variable).
Form B. Open form C (stores Form B in your global variable).
Form C. Close. (Opens Form B ... correct)
Form B. Close. (Opens Form B?? ... ermmmm)
No. Either use OpenArgs or any other way to pass the calling form's name to the form being opened. I personally use the Tag property since I often use OpenArgs for other things ^^
Thank you everyone.
Because i am already using the OpenArgs for another purpose, I had to be specific about using a function. So, in short form, this is what I did and, it works. Created a new code module then, delcared a public variable, set the variable in each calling form to be the name of the calling form then, used variable in the called form to return (stDocName = variable name).