[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

To Refresh Form... vb6

Posted on 2004-09-15
3
Medium Priority
?
1,767 Views
Last Modified: 2008-02-01
I have frmMain from which I access frmMaintenance (a popup form).  I click on cmdReset to:

cn.Execute "Delete * From tData"  'cn connection is global

frmMain.Form_Load           '<-- this gives error

The objective is to run Form_Load to remove all data from it (refresh it).  If I shouldn't be using Form_Load, how can I accomplish this task.

Thanks.                    
0
Comment
Question by:Mike Eghtebas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 32

Accepted Solution

by:
Erick37 earned 1200 total points
ID: 12071407
Make your own (Public) Sub or Function which contains the code to reinitialize your variables, etc.

ex:

Public Sub MyInit()
    'Code here to initialize your variables
    'Call this in Form_Load, and from outside the form
End Sub

You can call a Public sub from another form, you cannot call a Private sub - that's where I think your error is.



Hope it helps!
0
 
LVL 5

Assisted Solution

by:KarcOrigin
KarcOrigin earned 400 total points
ID: 12071490
Try to do this:
Although there are many ways to do this here are two ways to do it.
One way -
frmMain.Form_Load event always read the data from the DB and put the values of it on the form controls. When you click on cmdReset button unload frmMain and load frmMaintenance popup form. Now do DB operations as deleting the data and reload frmMain form by frmMain.Show() by this your frmMain's Form_Load will again fetch the fresh data and will place it in the controls.

Other way -
If you do not want to unload your frmMain while loading frmMaintenance popup form then I will suggest you to use public functions to fetch the data and store the values in some intermediate variables. Now use these functions/intermediate variables to fetch and place the data in the controls on frmMain form. For this you can create a class with properties to hold your database values and can use it to set the values in the controls.

This is a possible flow-

1. cmdReset button clicked
2. Call the function to fetch the data and place it in the intermediate variable(s)
3. Call a function/sub to clear the frmMain data
4. Call another function/sub which will place the values from these intermediate variable to your frmMain controls.

The above steps are just the overview and not in details.
Regards,

I hope it will help you.
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 12072018
Erick37's post what I was missing.  Generally, I would have changed 'Private Sub Form_Load()' to 'Public Sub Form_Load()' but somehow I missed it.

I used 'Public Sub InitializeForm()' As recomended by Erick37 because it is much cleaner.

----------
In appreciation of KarcOrigin's post, I am increasing the points to spit it.  I hope Erick37 wouldn't mind.

Regards,

Mike
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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

656 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