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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Minimizing and Opening Forms

Status
Not open for further replies.

ind

Programmer
Mar 9, 2000
121
US
I have two forms: Customers and Jobs<br>
<br>
On the customers I have a subform listing all the jobs for that customer. When you double-click the job number on the subform the job form opens showing that particular job, and the customers form minimizes. When the jobs form is closed I want the customers form to return to its previous state.<br>
<br>
However, I don't want the customers form to open everytime I close the jobs form.<br>
<br>
Is this possible???<br>
Thanks
 
You have to use a Global variable that you set to true if you open the form when you come to it.<br>
<br>
Ok it's called a toggle. Set it to True when you want to do something and False if you don't.<br>
Or it will be false becasue it was never set (such as opening the form manually)<br>
<br>
This is put in a Module like so<br>
Global OpenNow<br>
<br>
Of course the variable can be any name you like but it cannot have spaces in it.<br>
First set the variable to false in the forms Load event.<br>
OpenNow = False<br>
<br>
Then in your subforms event to launch it put <br>
OpenNow = True<br>
<br>
Now in your forms load event that you want to open put: <br>
If OpenNow Then<br>
'open form<br>
Else<br>
'don't open form <br>
End if<br>
<br>
OK<br>
<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
I'm not very practiced with modules. Can you please give me a more detailed example??
 
OK<br>
Click the modules TAB<br>
Then Click New button<br>
Then put this code in there<br>
Global OpenNow<br>
below the<br>
Option Compare Database<br>
line<br>
Then click Save and Module1 is OK for the name.<br>
<br>
Then Open your form that you will open first<br>
Click Design view<br>
Then Click the Properties for the form <br>
Look WAY down the list to Find &quot;On_load&quot; Event<br>
Clickit then click the down Arrow and Click &quot;Event Procedure&quot;<br>
Then click the &quot;3 dots&quot; button<br>
This will open Code window.<br>
Paste this under the &quot;Private Sub Form_Load()&quot;<br>
OpenNow = False<br>
<br>
OK <br>
Do the same for the others form<br>
When You open it &quot;On_Load&quot;<br>
<br>
If OpenNow Then<br>
'open form<br>
Else<br>
'don't open form <br>
End if<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
I still don't understand how to make the customers form be the active window when I close the jobs form.<br>
<br>
Please understand that I don't want the customers form to open everytime I open the jobs form. So the code:<br>
<br>
On Close()<br>
DoCmd.openform &quot;Customers&quot; <br>
will not work
 
If you're just looking for <i>easy</i>, here's a couple of suggestions. Don't bother minimizing the first form when the second form opens, as the second form would open on top by default when it receives the focus. Also instead of opening the second form with the special double-click, just use the button wizard to create a new button to open the second form based on whichever record is current in the first. This is sort of the standard approach.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top