Solved

reload a form

Posted on 2002-05-29
9
420 Views
Last Modified: 2008-03-03
Hi,
How can I close and reload the main form in my project without causing the application to completely exit.

In my case I want to close frmMain and Load frmMain but as soon as it is closed the project closes. Is there a way to do this?
0
Comment
Question by:adam8
  • 4
  • 3
  • 2
9 Comments
 
LVL 19

Accepted Solution

by:
Rimvis earned 50 total points
ID: 7043803
It's maybe because you STARTUP FORM is frmMain. Try to change it to Sub Main and add some code that handles form reloading there.
0
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7043807
Why do you want to do this, if you are closing a form which is the main form in your application, that means you are closing your application. That's it!

Or do you want to something else, like refresing some variables. Just wanted to know why you are doing this, maybe there is a better way to accomplish.

-priya

0
 
LVL 1

Author Comment

by:adam8
ID: 7043810
I want to clear listviews and image lists and all the variables on a form and so much stuff that i thought it would be easier to reload the form.

If I use a module and make Sub Main then wouldn't that mean I could keep a form running in the background. That way the app wouldn't close until the hidden form closed.

I am not sure
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 1

Author Comment

by:adam8
ID: 7043812
Rimvis,I hadn't read your comment.

How would I go about this, I know how to start the app up from submain but how would I make sure teh application didn't close until i wanted it to.

Hopefully without using loops in the submain.
0
 
LVL 19

Expert Comment

by:Rimvis
ID: 7043819
Here's a sample

Module1 code:
-------------------
Option Explicit

Sub Main()
    Form1.Show
End Sub

Public Sub Reload()
    Form1.Show
End Sub

Form1 code:
-----------------------
Option Explicit

Private Sub cmdTest_Click()
    Unload Me
    Reload
End Sub

----------------------------


Works for me :o)

0
 
LVL 1

Author Comment

by:adam8
ID: 7043836
it works for me when I try it on a new prioject but doesn't work on my program. I will try again.

0
 
LVL 19

Expert Comment

by:Rimvis
ID: 7043837
Maybe you have 'End' statement in your frmMain_Unload event?
0
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7043842
Try making the starup form as submain

Go to Project, Project Properties, General Tab, StartUp object as "Sub Main"

That maybe help!

0
 
LVL 1

Author Comment

by:adam8
ID: 7043843
I know why, I had an End statement at the end of the Form_Unload statement to ensure it closed (what an idiot am I)

I feel a bit stupid now.

Thanks for the help.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Reading the Contents of a Directory In Access VBA 5 68
Updates not working for MS Windows 7 12 165
Microsoft Access combo box help 2 46
Help me. 3 54
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

773 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