Link to home
Start Free TrialLog in
Avatar of iamdaedal
iamdaedal

asked on

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?
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

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
Avatar of iamdaedal
iamdaedal

ASKER

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...  :/
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.
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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