any system variabes for "previous form"?

ryetee

Registered User.
Local time
Today, 20:13
Joined
Jul 30, 2013
Messages
970
I've inherited an Access 2010 database that needs tweaking.
I have a form, let's call it CALLED_FORM, that is loaded from various places - ie there are quite a few places that do the following

DoCmd.OpenForm "CALLED_FORM", , , , , , coupleofarguments

This works great when called from most places but if it is called from 1 specific form there is a likelihood that some code is executed that shouldn't be.

So I want to be able to do the following

In CALLED_FORM I want to be able to skip some code if the previous form is say FORMX. For all other forms I want it executed.

eg

If PREVFORM <> "FORMX" then
code
more code
even more code
End If

Is there a system variable for PREVFORM.

I know I can change coupleofarguments to threearguments and pass something over in that to show which form it has been called from but that is a bit of a pain.

Anything I can do?

Dave
 
Aside from your own thought on passing a third component in the OpenArgs, you could use either a Global Variable or TemVars.
  • Create the Global Variable or TemVars and set it to a default value
  • In the Form in question, prior to DoCmd.OpenForm command, set the Global Variable or TemVars to a non-default Value.
  • In the secondary Form, check the Global Variable or TemVars and only run the special code if it isn't equal to the non-default Value. After that code runs or doesn't run, depending, rest the Global Variable or TemVars to the default Value.
Linq ;0)>
 
Aside from your own thought on passing a third component in the OpenArgs, you could use either a Global Variable or TemVars.
  • Create the Global Variable or TemVars and set it to a default value
  • In the Form in question, prior to DoCmd.OpenForm command, set the Global Variable or TemVars to a non-default Value.
  • In the secondary Form, check the Global Variable or TemVars and only run the special code if it isn't equal to the non-default Value. After that code runs or doesn't run, depending, rest the Global Variable or TemVars to the default Value.
Linq ;0)>

Thanks for this - I decided to go down another route!!
I used If CurrentProject.AllForms("CALLED_FORM").IsLoaded then else code end if

I only have to change 1 form in this case.
 
If the operation was initiated by a button click you might also check Screen.PreviousControl.Parent. That might hold a reference to the previous form.
 

Users who are viewing this thread

Back
Top Bottom