By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,168 Members | 2,599 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,168 IT Pros & Developers. It's quick & easy.

Form Load Event runs 3 times

P: n/a
My Load event is running 3 times.
I'm calling the form two different ways, and it always runs 3 times. As you
can imagine, this makes the load time slow!
Any help appreciated.
Vayse
Method 1:
Dim fAsset As New frmAsset

fAsset.AssetView = fAsset.ViewAsset
fAsset.AssetCode = stAssetCode
fAsset.Show()

Method 2:
Dim fAsset As New frmAsset

fAsset.AssetView = fAsset.ViewAll
fAsset.Show()

'************************************************* *******************
Private Sub frmAsset_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load, MyBase.Load, MyBase.Load

Me.ScheduleTableAdapter.Fill(Me.AssetsDataSet.Sche dule)
Me.MethodsTableAdapter.Fill(Me.AssetsDataSet.Metho ds)
Me.SubCatgsTableAdapter.Fill(Me.AssetsDataSet.SubC atgs)
Me.StatusTableAdapter.Fill(Me.AssetsDataSet.Status )
Me.SuppliersTableAdapter.Fill(Me.AssetsDataSet.Sup pliers)
Me.DeptsTableAdapter.Fill(Me.AssetsDataSet.Depts)
Me.CostCentresTableAdapter.Fill(Me.AssetsDataSet.C ostCentres)

iOpened += 1
Try
Select Case iAssetView
Case conVIEW_ASSET
Debug.Print(iAssetView & ": One & " & iOpened)
Me.AssetsTableAdapter.FillByAsset(Me.AssetsDataSet .Assets,
stAssetCode)
Case conVIEW_SUB
Debug.Print(iAssetView & ": Sub & " & iOpened)
Me.AssetsTableAdapter.FillBySub(Me.AssetsDataSet.A ssets,
lSubCatgID)
Case Else
Debug.Print(iAssetView & ": All & " & iOpened)
Me.AssetsTableAdapter.Fill(Me.AssetsDataSet.Assets )
End Select
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try

bLoaded = True

End Sub
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
In message <ez*************@TK2MSFTNGP15.phx.gbl>, Vayse
<Va***@nospam.nospam> writes
Private Sub frmAsset_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load, MyBase.Load, MyBase.Load

I draw your attention to the "Handles" part of your statement

--
Chris Petchey
Nov 21 '05 #2

P: n/a
And now that I review my mail, I see why!
For some reason, theres 3 mybase.load
Handles MyBase.Load, MyBase.Load, MyBase.Load

I wonder how I did that?
Vayse

"Vayse" <Va***@nospam.nospam> wrote in message
news:ez*************@TK2MSFTNGP15.phx.gbl...
My Load event is running 3 times.
I'm calling the form two different ways, and it always runs 3 times. As
you can imagine, this makes the load time slow!
Any help appreciated.
Vayse
Method 1:
Dim fAsset As New frmAsset

fAsset.AssetView = fAsset.ViewAsset
fAsset.AssetCode = stAssetCode
fAsset.Show()

Method 2:
Dim fAsset As New frmAsset

fAsset.AssetView = fAsset.ViewAll
fAsset.Show()

'************************************************* *******************
Private Sub frmAsset_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load, MyBase.Load, MyBase.Load

Me.ScheduleTableAdapter.Fill(Me.AssetsDataSet.Sche dule)
Me.MethodsTableAdapter.Fill(Me.AssetsDataSet.Metho ds)
Me.SubCatgsTableAdapter.Fill(Me.AssetsDataSet.SubC atgs)
Me.StatusTableAdapter.Fill(Me.AssetsDataSet.Status )
Me.SuppliersTableAdapter.Fill(Me.AssetsDataSet.Sup pliers)
Me.DeptsTableAdapter.Fill(Me.AssetsDataSet.Depts)
Me.CostCentresTableAdapter.Fill(Me.AssetsDataSet.C ostCentres)

iOpened += 1
Try
Select Case iAssetView
Case conVIEW_ASSET
Debug.Print(iAssetView & ": One & " & iOpened)

Me.AssetsTableAdapter.FillByAsset(Me.AssetsDataSet .Assets, stAssetCode)
Case conVIEW_SUB
Debug.Print(iAssetView & ": Sub & " & iOpened)

Me.AssetsTableAdapter.FillBySub(Me.AssetsDataSet.A ssets, lSubCatgID)
Case Else
Debug.Print(iAssetView & ": All & " & iOpened)
Me.AssetsTableAdapter.Fill(Me.AssetsDataSet.Assets )
End Select
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try

bLoaded = True

End Sub

Nov 21 '05 #3

P: n/a
Hi

I did not understanding your scenario very clear, what is your question now?
If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #4

P: n/a
Its all ok now, thanks.

""Peter Huang" [MSFT]" <v-******@online.microsoft.com> wrote in message
news:9h**************@TK2MSFTNGXA01.phx.gbl...
Hi

I did not understanding your scenario very clear, what is your question
now?
If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no
rights.

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.