Good day, I would ask for your help, my code below is giving me an error whether I open my new window(application/form?) resulting to appearance of the error "Object reference...." first before the said application. What is the problem in this codes? Thank you for your help. =)

    Private Sub searchacquisition_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles searchacquisition.TextChanged
            Dim SQL1 As String
            SQL1 = "Select * from newacquisition"
            OleA.Fill(Dset, "newacquisition")
            Dim col2 As New AutoCompleteStringCollection
            Dim c As New Integer
            For c = 0 To Dset.Tables("newacquistion").Rows.Count - 1


            searchacquisition.AutoCompleteSource = AutoCompleteSource.CustomSource
            searchacquisition.AutoCompleteCustomSource = col2
            searchacquisition.AutoCompleteMode = AutoCompleteMode.Suggest
        Catch ex As Exception
        End Try
    End Sub


Recommended Answers

All 2 Replies

It would help to know which line was referenced in the error.

If I'm not mistaken, generally that error is from not initializing an object when it is declared, then trying to give it a value. In your code SQL1, Dset, searchacquisition, OleA might fall in that category. SQL1 is simple, try this, Dim SQL1 As String = "Select * from newacquisition". It looks like searchacquisition is a textbox, so it should be OK. That leaves Dset and OleA to check in you're other code.


The error you are receiving, appears when for example we do not initialize an object and try to access one of its property so in this case the the object does not exists so we can not access its property.

I have a couple of questions and few guidelines for you:


1) Have you tried to step debug it?
2) Have you checked which line is the cause of this error ?


1) Verify that, is 'OleA' variable initialized ?
2) In these lines:

OleA.Fill(Dset, "newacquisition")

what is your intentions here ? Is it a TWO times fill ? 'OleA.Fill' is already filling 'Dset' with data. Isn't it ?

3) Make sure this at this line :


we have a table inside which contains atleast one table with name "newacquisition" and a column in it with name "title".

4) Is search 'searchacquisition' variable initialized ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.