Error: Object reference not set to an instance of an object.
Posted on 2006-12-01
Hmmm...I'm not sure what's wrong here. I am getting the Object reference not set to an instance of an object error, and I'm not sure what I need to do different. I've used, almost, the exact same routine elsewhere, just as it is, with success
I have a combobox, called cmbEventList, and I want to update it, from another form. Simply trying the cmbEventList.Text = NewEventName (String), doesn't work (no error, but it doesn't update it). So I decided to go the Public Property route. Now, the only problem is, using it, I get the aforementioned error.
Here is my main form:
Private Sub SCMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
frmUpdateEventName.SCMainClass = Me
Private Sub btnUpdateEventNameRU_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateEventNameRU.Click
Dim UpdateEventName As New frmUpdateEventName
UpdateEventName.Visible = True
Public Class frmUpdateEventName
Public mySCMain As SCMain
Public Property SCMainClass() As SCMain
SCMainClass = mySCMain
Set(ByVal Value As SCMain)
mySCMain = Value
Dim tableToUpdate As String = Nothing
Private Sub UpdateEventName_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtOldEventName.Text = SCMain.cmbEventName.Text()
txtNewEventName.Text = SCMain.cmbEventName.Text()
Private Sub btnUpdateEventNameNow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateEventNameNow.Click
Dim dbUpdate As New databaseInteractions_Update
Dim NewEventName As String = txtNewEventName.Text()
dbUpdate.UpdateDatabase_String(SCMain.RUdsn, tableToUpdate, "EventName", NewEventName, "WHERE EventName = '" & txtOldEventName.Text() & "'")
mySCMain.cmbEventName.Text = NewEventName '<--------- It dies here
Is somebody seeing something I'm not, or am I missing something.
Thanks in advance!