I have a form which has a search feature - a single text field and command button; when the text field is filled-in a database query is executed and the result (if one result returned) is shown on the form via dynamic control fields.
When the search feature is used for the first time, the fields are created and the data is returned from the database, however when the search feature is re-ran I am getting the error "Object Reference not set to an instance of an object", the error occurs at:
initSearch(txtSearchInput.Text)
I am guessing that I am not handling the textfield properly for this type of use, can anyone please advise how else I should be doing this?
The txtSearchInput is not a dynamic field, it has been created through the design mode, the same for the command button. The above code is located in the command button On Click event:
Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click
Try
initSearch(txtSearchInput.Text)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Error Encountered")
End Try
End Sub
Any help would be greatly appreciated.
Thanks,
Matt