Access -- Close a form and return to the form that called me

I have a record detail form that can be invoked from any of three other forms. How do I code to correctly restore the form that invoked it when I exit?
iamdaedalAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You have to store the name of the "calling form", and then use that when the "called form" closes. For example:

DoCmd.OpenForm "CalledForm", , , , , , Me.Name

This passes the name of the "callingform" in the OpenArgs section. You'd then have to store that name somewhere in the "calledform". You could add a hidden textbox to your form (name it "txCallingForm"), and then do this in the Form's Open event:

Me.txCallingForm = Nz(Me.OpenArgs,"")

Finally, in the Close event of the form:

If Nz(Me.OpenArgs, "") <> "" Then
  Forms(Me.txCallingForm).SetFocus
End If
0
iamdaedalAuthor Commented:
I was not able to get the OpenArgs solution to work, and ran out of time on my project delivery date to try to ramp up to a sufficient understanding to implement it. Add to that  the fact that I don't understand the Nz function, even after reading as much about as I could find here and on MS's documentation. I left the idea behind and found a simpler solution that fit my limited skills and kept me on track with my deadlines. Will try to revisit this when time and opportunity permit.

Thanks to LMSConsulting for your offering. Oh, and sorry for the delay in responding. Been seriously out-of-pocket for a while and unable even to open up the laptop...  :/
0
iamdaedalAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for iamdaedal's comment #a39584297

for the following reason:

Went with a solution that didn't require an understanding of this concept and no longer require the answer.
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
The comment you accepted isn't really an answer, since you didn't post any details of your solution, and you should not accept it as a solution. Either post the details of your solution and accept that, or accept my comment, or delete the question.

FWIW, my original comment was incorrect regarding the correct way to "recall" the calling form. The last bit of code should have read like this:

If Nz(Me.txCallingForm, "") <> "" Then
  Forms(Me.txCallingForm).SetFocus
End If

The Nz function is the "Null to Zero" function. It converts a Null value into what you pass in as the second argument, so Nz(Me.txtCallingform, "") would return either (a) the value in txCallingForm or (b) a zero length string ("").

Since my original comment contained invalid advice, you could just delete the question.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
iamdaedalAuthor Commented:
Voicing an 'objection' is stronger than I imagine is called for. Certainly I had issues with the solution as originally provided and my circumstances didn't allow for me to engage in an open debate about its relative merits, especially since I hadn't seen his amended solution until just now. Will try this newly formed solution and come back with my findings...

daedal
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.