Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning to the correct form!

Status
Not open for further replies.

ShaneBrennan

Programmer
May 19, 1999
198
0
0
GB
Okay where do I begin.<br><br>Right I have a form, called Customers, which is used to maintain a table of Known Customers/People of a company.<br><br>I have two forms, each of which need to run the Customers form, but before it does the calling form's visible property is set to false.&nbsp;&nbsp;Once the customer form is closed I need to make the calling form visible again.<br><br>What I need is a section of code to do the following algorithm.<br><br>IF Invoice_form = present and invisible THEN<br>&nbsp;&nbsp;&nbsp;Close Customer Form<br>&nbsp;&nbsp;&nbsp;Set Invoice_form.visble = true<br>else<br>&nbsp;&nbsp;&nbsp;Close customer Form<br>&nbsp;&nbsp;&nbsp;set Main_Menu_Form.visible = true<br>endif<br><br>Thanks for any help I recieve.<br><br>Shane Brennan<br><br> <p> Shane Brennan<br><a href=mailto:brennans@tcat.ac.uk>brennans@tcat.ac.uk</a><br><a href= > </a><br>
 
Copy and paste the following function into a module:<br><br>==========<br><br>Function IsLoaded(ByVal strFormName As String) As Boolean<br>&nbsp;&nbsp;&nbsp;&nbsp;'Purpose: Determines if a given form is loaded<br>&nbsp;&nbsp;&nbsp;&nbsp;'If IsLoaded(&quot;FormName&quot;) then ...<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;Const conObjStateClosed = 0<br>&nbsp;&nbsp;&nbsp;&nbsp;Const conDesignView = 0<br>&nbsp;&nbsp;&nbsp;&nbsp;If SysCmd(acSysCmdGetObjectState, acForm, strFormName) &lt;&gt; conObjStateClosed Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If Forms(strFormName).CurrentView &lt;&gt; conDesignView Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IsLoaded = True<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>End Function<br><br>==========<br><br>Now copy this code to the OnClose event of your customer form:<br><br>==========<br><br>Private Sub Form_Close()<br>&nbsp;&nbsp;&nbsp;If IsLoaded(&quot;Main_Menu_Form&quot;) Then Forms!Main_Menu_Form.Visible = True<br>&nbsp;&nbsp;&nbsp;If IsLoaded(&quot;Invoice_Form) Then Forms!Invoice_Form.Visible = True<br>&nbsp;&nbsp;&nbsp;Docmd.Close acForm, &quot;Customers&quot;<br>End Sub <p>Jim Lunde<br><a href=mailto:compugeeks@hotmail.com>compugeeks@hotmail.com</a><br><a href= Application Development
 
For the simle case of two 'parents' supporting one child, the above is o.k.&nbsp;&nbsp;If you expand the system (and what system doesn't expand?), it becomes easier to maintain a &quot;list&quot; of forms in the order of opening and just return to the previous.&nbsp;&nbsp;Another option for the 'few' forms is just to place the name of the callling form in a global variable, and use the global var as the form to return to.
 
Or save a little memory (&quot;no one will ever need more than 640K&quot;) and pass Me.Name to the routine that will make Me visible when it closes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top