Perform automatic function After form loads?

Posted on 2005-05-05
Medium Priority
Last Modified: 2010-04-23
I have an SQL connection that I need to run on my form when the form loads but if I put it in the form load sub the form doesn't show up untill the connection is complete or an error occurs.

How can I automatically run the function but allow the user to see the form while it runs?
Question by:Matrix1000

Assisted Solution

gdexter earned 800 total points
ID: 13939054
Try setting

Form.Visible = True

in the Load event before you create the connection.
LVL 38

Accepted Solution

PaulHews earned 1200 total points
ID: 13939068
If you put me.visible = true in form_load before connection, then the form will show before making the connection.  You might want an Application.DoEvents or even Me.Refresh to make sure the form is painted before making the connection.  Simple example:

  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Text = "HAHAHA"
        Me.Visible = True
        Me.Text = "Form1"

    End Sub

If you comment out Me.Visible, then you won't see the form until 3 seconds has elapsed and the title is back to Form1

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses
Course of the Month9 days, 16 hours left to enroll

569 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