none
Find method of the DataView object refuses to find letter "A" RRS feed

  • Question

  • Isn't this bizarre?!  I have this little code, I connect to an Access database, I fill the DataSet and DataView. I have a value “A” in the column I search. If I select the item showing letter “A” in the ComboBox the Find method does NOT find it. If I Type the letter “A” in the ComboBox then it finds it. Any other item can be found with the Find method but the letter “A”.

     

    What gives??!

     

     

    Code Snippet

    If ComboBox1.SelectedIndex <> -1 Then

    objDataView1.Sort = "Description100"

    If objDataView1.Find(Trim(ComboBox1.Text.ToString)) > 0 Then

    'Stop

    Else

    Stop

    End If

    End If

     

     

    Thanks for pointers!
    Monday, August 13, 2007 5:33 PM

Answers

  • It's a desktop application.

     

    Now, I  have more info. It is not necessarily the latter "A" that is not found, is the first item in the list.

     

    The proble actually is Find returns -1 if it does not find anything, so this line:

    If objDataView1.Find(Trim(ComboBox1.Text.ToString)) > 0 Then

    Should be:

    If objDataView1.Find(Trim(ComboBox1.Text.ToString)) > -1 Then

    Monday, August 13, 2007 6:27 PM

All replies

  • You are doing this for Web or Desktop Application.

     

    Regards,

    Wasif Ahmad

    Monday, August 13, 2007 6:13 PM
  • It's a desktop application.

     

    Now, I  have more info. It is not necessarily the latter "A" that is not found, is the first item in the list.

     

    The proble actually is Find returns -1 if it does not find anything, so this line:

    If objDataView1.Find(Trim(ComboBox1.Text.ToString)) > 0 Then

    Should be:

    If objDataView1.Find(Trim(ComboBox1.Text.ToString)) > -1 Then

    Monday, August 13, 2007 6:27 PM