Closing form back to the right path.

sir_aingeal

Registered User.
Local time
Today, 14:16
Joined
Nov 5, 2002
Messages
21
I have a form which can be opened from 2 different paths. One from the person who will use it and access it one way, and one from the supervisor who has access to a number of these forms used by different departments.

What I want to do if possible is have the form remember where it was opened from and close back to the correct opening from.

Any suggestions gratefully received.


Thanks
Iain
 
Hi,

When you open the form with DoCmd.OpenForm, the last argument is "OpenArgs". Give here the name of the calling form as string, for example:
Code:
DoCmd.OpenForm "CalledForm", , , , , , "CallingForm"
Then in the UnLoad-event of the form you put:
Code:
Private Sub Form_Unload(Cancel As Integer)
  DoCmd.OpenForm Me.OpenArgs
End Sub
to re-open form "CallingForm"
 
This could be standardised even further using

Code:
[b]DoCmd.OpenForm "CalledForm", , , , , , Me.Name[/B]
 
Thanks for the try guys but it did not work, and did not come up with any errors either.:confused:
 
Can you set a breakpoint in the Unload-event-code te see if it's running?
 
Have you, by chance, put both snippets of code on the same form?
 
The first part is in the on click of the calling form and the second part is in the unload event of the called form. Which is the way I read it to go.
 
Please tell us: what doesn't work?
Is your second form opened by the OnClick-event of the button on the calling form?
If Yes, then try (while the second form is open) by going to the immediate window typing this:
Code:
? Forms!SecondFormName.OpenArgs
Then press Return. Is the name of the calling form printed now in the next line?
 
Got it fixed.

I had an open form argument in the code in the wrong place.

DUH
 

Users who are viewing this thread

Back
Top Bottom