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?
Who is Participating?
Scott McDaniel (Microsoft Access MVP - EE MVE )Connect With a Mentor 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
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.
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
End If
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...  :/
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.
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...

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.