V. URGENT! Odd NullReferenceException problem...

In the following code, how is the line after the comment causing a NullReferenceException on 3 of our test machines  It doesn't cause any problems on mine, or two of the other test machines, and it definitely shouldn't cause a NullReferenceException immediately after I check if the referenced object is Nothing. I have a feeling that this could be a referenced Access/ADODB library problem, but am not sure how ta handle it.

            strFile = Me.ofdDBSelect.FileName

            strSourceTable = InputBox("SELECT * FROM: ", "Source Table", "New Section")
            strDestTable = InputBox("INSERT INTO: ", "Destination Table", "tblStuff(2)")

            Try
                Me._myFile = New Access.Application
                If (Me._myFile Is Nothing) Then
                    Throw New Exception("Application could not be accessed!")
                End If
        'This line:
                Me._myFile.OpenCurrentDatabase(strFile)
                If (Me._myFile.CurrentDb Is Nothing) Then
                    Throw New Exception("Application could not be accessed!")
                End If
                objTable = Me._myFile.CurrentDb.TableDefs(strDestTable)
                If (objTable Is Nothing) Then
                    Throw New Exception("Table '" & strDestTable & "' could not be opened!")
                End If

Regards.

Stephen.


Answer this question

V. URGENT! Odd NullReferenceException problem...

  • John2006

    My guess is that this is a db permissions issue (not allowing access from the other computers)
  • V. URGENT! Odd NullReferenceException problem...