Mike

Mike

  • NA
  • 2
  • 0

Problems with RaiseEvent

Jun 5 2007 3:42 PM
Hello all. I have a problem which is driving me up a wall. I am using two forms: Form2 is a child of Form1. Form1 contains a data bound grid which displays summaries of related Form2. When data in Form2 is saved (either an insert or an update), I raise an event, and I handle that event in Form1 by refreshing the grid. New/Update is determined by If/Then/Else. Here's the pertinent code:

Form1:
Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
Dim EditPromo As New frmPromo
EditPromo.NewRecord =
False
EditPromo.RecordID = dbgPromos.Item(dbgPromos.CurrentRowIndex, 0)
EditPromo.ShowDialog()

AddHandler EditPromo.ItemSave2, AddressOf RefreshGrid
End Sub

Private Sub RefreshGrid()
Dim CM As CurrencyManager
'DA is a data access class which handles all of the SQLClient stuff.
m_Promos = DA.RunSPGetDS("SelectCampaignPromos", DA.CreateParam("@CampaignID", txtCampaignID.Text)).Tables("CampaignPromos")

'dataview declared at beginning of class
DV.Table = m_Promos
dbgPromos.DataSource =
Nothing
dbgPromos.DataSource = m_Promos

CM = BindingContext(dbgPromos.DataSource, dbgPromos.DataMember)

End Sub



Form2:

Private Sub SavePromo()

If m_New = True Then
Dim ID As New DataTable
ID = DA.RunSPGetDS("SelectNewPromoID").Tables("NewPromoID")
txtPromoID.Text = ID.Rows(0).Item("NewID")
DA.RunSP("InsertPromo", DA.CreateParam("@MCCampaignID", txtCampaignID.Text),_
DA.CreateParam("@MCPromoDescription", txtDescription.Text), _
DA.CreateParam("@MCPromoID", txtPromoID.Text), _
DA.CreateParam("@MCPromoNotes", txtNotes.Text))

Else
'when updating an existing record
DA.RunSP("UpdatePromo", DA.CreateParam("@PromoID", txtPromoID.Text), _
DA.CreateParam("@MCPromoDescription", txtDescription.Text), _
DA.CreateParam("@MCPromoNotes", txtNotes.Text))
End If

RaiseEvent ItemSave()

End Sub


When I run the app and take it through the ELSE section, the event is not raised.  I've tried splitting out the IF/Then/Else into separate subs, no difference. The grid on Form1 does not refresh.

Any suggestions or advice would be greatly appreciated.

Mike