martin2k

Google
 
Web www.martin2k.co.uk

Form Loading


Home Read and add posts to the Visual Basic 6.0 Forums Download some of my programs and OCXs Read the Tips here The old style forum is still available here Contact

Back


From: mike E-mail: mduncalf@hotmail.com 1

Date: Monday, August 20, 2001 at 16:58:38

Subject: Form Loading

Comments:

I'm trying to use the following code so that when my form loads in my project the text boxes are updated with information from my database. As far as I can tell, this code is the same as for 3 other forms in my project, which all load perfectly fine, but whatever code I use for this form I get an error. What's wrong?

Option Explicit

Private Sub cmdClose_Click()
    Form5.Hide      'when the close button is clicked, hide the form
    Unload Form5

    Form1.Show      'show form 1
End Sub

Private Sub updateFields()
    txtEntitlement.Text = DataEnvironment1.rsHolidaySick.Fields("Entitlement")
    txtTaken.Text = DataEnvironment1.rsHolidaySick.Fields("Taken")
    txtRemaining.Text = DataEnvironment1.rsHolidaySick.Fields("Remaining")
    txtSickEntitlement.Text = DataEnvironment1.rsHolidaySick.Fields("Sick Entitlement")
    txtSickTaken.Text = DataEnvironment1.rsHolidaySick.Fields("Sick Taken")
    txtSickRemaining.Text = DataEnvironment1.rsHolidaySick.Fields("Sick Remaining")
    'update the text boxes with data from the relevant database fields
End Sub

Private Sub Form_Load()
    updateFields    'initiate the update fields command when the form loads
End Sub

 
From: Jonathan Grotell E-mail: grotelljd@bernstein.com 2

Date: Wednesday, September 12, 2001 at 14:27:22

Subject: RE: Form Loading

Comments:

I've seen this before where certain controls are not initialized at the Form_Load event. In this case, I would move this code to the Form_Activate() method, and put a flag in the form so that this code will not fire every time the form is activated (viewed).


This forum is no longer taking new messages or replies since 01 November 2002.  The above material is for reference purposes only.

The new Visual Basic 6.0 forum can be found here.


Martin Allen 1999 - 2003.  Last updated Monday 12 May 2003 08:03:39 PM +0100.