• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 430
  • Last Modified:

reload a form

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
adam8
Asked:
adam8
  • 4
  • 3
  • 2
1 Solution
 
RimvisCommented:
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
 
priya_pbkCommented:
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
 
adam8Author Commented:
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
adam8Author Commented:
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
 
RimvisCommented:
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
 
adam8Author Commented:
it works for me when I try it on a new prioject but doesn't work on my program. I will try again.

0
 
RimvisCommented:
Maybe you have 'End' statement in your frmMain_Unload event?
0
 
priya_pbkCommented:
Try making the starup form as submain

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

That maybe help!

0
 
adam8Author Commented:
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

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now