Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Reloading a form.

Posted on 2003-03-28
10
Medium Priority
?
312 Views
Last Modified: 2010-04-07
Is there anyway I can reload the form after say clicking a button.  Whenever I load the form the first time it can load it the way I state it in the formload procedure, but then once I hide it and want to load it back up again, it will be the same as the last time I left it.

Is there a way I can just refresh and reload it to its defaults everytime?


Thanks.
0
Comment
Question by:n-generation
10 Comments
 

Expert Comment

by:PeterNolan
ID: 8223990
Change the Form_Load to Form_Activate.

The Form_Activate will come on everytime the form is the "main", or visible one.

Peter
0
 
LVL 55

Accepted Solution

by:
Ryan Chong earned 150 total points
ID: 8224058
2 method:

1st method: save all the setting in a sub, then when the form is showing again, execute the sub again, something like PeterNolan mentioned.

2nd method: unload frm, then load frm again.

cheers
0
 
LVL 39

Expert Comment

by:appari
ID: 8224061
or whatever code you want to execute more than once write it in a sub/function and call it from formload and other command button click.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 6

Expert Comment

by:VK
ID: 8224249
Hello n-generation.

Suggestion:

1. All the things which are to do only once´with the form:
0
 
LVL 6

Expert Comment

by:VK
ID: 8224263
Hello n-generation.

Suggestion:

1. All the things which are to do only once with the form:
   Form_Initialize
2. All the thing which are to do every time the form loads:
   Form_Load
3. All the things which are to do when the form becomes visible or gets the focus:
   Form_Activate

V.K.
0
 
LVL 5

Expert Comment

by:Cimperiali
ID: 8224393
Or simply explicitly call the Load_Form where you need
ie:
Private sub Command1_Click()
   Call Form_Load()
End Sub
0
 
LVL 1

Expert Comment

by:gmsolutions
ID: 8224500
Your button should simply set frmForm.visible = false
then frmForm.visible = true to reveal it again with all the prevouse settings.

for example if you have a form named fmMooo and it is allready loaded you can simply set it from some sub in a module.

if you are managing a lot of forms say through a collection or other means set the property through that. ie

dim x as frmMoo

sub main


end sun
0
 
LVL 1

Expert Comment

by:gmsolutions
ID: 8224501
Your button should simply set frmForm.visible = false
then frmForm.visible = true to reveal it again with all the prevouse settings.

for example if you have a form named fmMooo and it is allready loaded you can simply set it from some sub in a module.

if you are managing a lot of forms say through a collection or other means set the property through that. ie

dim x as frmMoo

sub main


end sun
0
 
LVL 1

Expert Comment

by:gmsolutions
ID: 8224544
sorry about that. accedental press of the tab + enter key.


Your button should simply set frmForm.visible = false
then frmForm.visible = true to reveal it again with all the prevouse settings.

for example if you have a form named fmMooo and it is allready loaded you can simply set it from some sub in a module.

if you are managing a lot of forms say through a collection, array or other means set the property through that.
my prefered method of managing forms is by name through a collection or by creating a new instance using the original as a template.
ie

dim x as frmMoo

sub main
 set x = new frmMo
 x.show
end sub


public sub showmoo
 x.visible = true
end sub

public sub hidemoo
  x.visible = true
end sub


0
 
LVL 1

Expert Comment

by:gmsolutions
ID: 8224554
oh did i forget to mention add a public function that allows you to reset the form.


public sub showmoo(optional blreset = false)
 if blReset then x.resetdetails
 x.visible = true
end sub
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

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

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.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month10 days, 22 hours left to enroll

572 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