[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How do I open a form using same session as the application

Posted on 2006-05-31
17
Medium Priority
?
166 Views
Last Modified: 2010-04-30
I have this application which contains several forms. Everytime I open a form, i open one too nay sessions and when I close it, the sessions don't close out unless I close the application. Pls. advise. Thanks
0
Comment
Question by:MonNerd
  • 6
  • 5
  • 2
  • +1
14 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 16801089
I don't know about anybody else, but your question is hard for me to understand.

You open a form like this:
Form1.Show.

What sort of sessions do you have too many of?
0
 
LVL 14

Expert Comment

by:Matti
ID: 16801234
Hi!

I'm not sure is this about some loaded form which prevent your app closing, then you see many open programs in taskmanagers screen, try this on Form_Unload event:

Public Sub UnloadAllForms()
   Dim Form As Form
   For Each Form In Forms
      Unload Form
      Set Form = Nothing
   Next Form
End Sub

Matti
0
 
LVL 1

Expert Comment

by:untarded
ID: 16802595
Are you creating instances of the forms.  To guarantee that your forms are being handled you should create and destroy the instances of your forms.

rather than setting the show property of a form such as

 form1.show

create an instance of the form

'declare and create an instance of Form1
Dim oForm1 as Form1
Set oForm1 = New Form1
'show the instance
oForm1.Show
'when you are finished with your form
Unload oForm1
Set oForm1 = nothing


This will give you better control of how many forms are in memory at a given time. You can unload the forms individually or loop through them with Matti's example above.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:MonNerd
ID: 16818240
I am doing all of the above..Sometimes it even loads other forms without having to open it up. why???Oh why???
0
 
LVL 14

Expert Comment

by:Matti
ID: 16818304
Hi!

When something on a different form is caled, it causes automaticly load that form.
For example Set Picture1.Picture = Form2.Picture1.Picture
Is there form names like this in Your code?

Matti
0
 
LVL 1

Expert Comment

by:untarded
ID: 16818489
Can you post your code?
0
 
LVL 1

Author Comment

by:MonNerd
ID: 16904988
Its a huge application. Which part of the code would you like to see...

Matti,

The Picture1.picture is not there...Thanks
0
 
LVL 14

Expert Comment

by:Matti
ID: 16909243
Hi!

It could be difficult , that was a sample from the kind of cause you could have there.

Have you tried the code in my first post?

Put line "UnloadAllForms" on main forms Form_Unload event.

Does it stop the problem behavior?

Matti
0
 
LVL 1

Author Comment

by:MonNerd
ID: 16914106
Yup... Already has the code....
0
 
LVL 1

Author Comment

by:MonNerd
ID: 16951767
Guess what... The code checks to see whether form is empty or not using the Isempty function. If its not empty then it does not close the form... This code has been written by someone else... So what now...
0
 
LVL 14

Accepted Solution

by:
Matti earned 2000 total points
ID: 16952066
Hi!

Remove that code, on main form put this UnloadAllForms there, it will set every form nothing, so don't need any other way to release memory.

Matti
0
 
LVL 1

Author Comment

by:MonNerd
ID: 16954445
Hi Matti,
On the main id I do have the Unload all forms... but what if I've to reopen a  form again & again & again without having to close the main, the form shows as open as many times as you open. Closing a form does not seem to do anything.

Have I confused you enough?? Ha!Ha!
0
 
LVL 14

Expert Comment

by:Matti
ID: 16957641
When you exit the main form you need to close and run that UnloadAllForms code.

Do you have code in these events of those forms:

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

Private Sub Form_Unload(Cancel As Integer)

What kind of code?
That could prevent program ending normally.


Matti




0
 
LVL 1

Author Comment

by:MonNerd
ID: 16993328
All the forms have code in their event unload but not queryunload..
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month19 days, 16 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question