Im just not seeing where the cast exception is coming from. Any help appreciated.
An unhandled exception of type System.InvalidCastException occurred in microsoft.visualbasic.dll
Additional information: Cast from string "SELECT Description Like %CRC%" to type Long is not valid.
The code is setup to take a user-entered criteria from a text box once a "select all" value from a listbox has been selected. It then cycles through each column looking for the user-defined string. The code works just fine when a specific column heading is selected from the listbox so I dont understand why the use of multiple column headings in a SQL/OR or statement doesnt also work.
An unhandled exception of type System.InvalidCastException occurred in microsoft.visualbasic.dll
Additional information: Cast from string "SELECT Description Like %CRC%" to type Long is not valid.
The code is setup to take a user-entered criteria from a text box once a "select all" value from a listbox has been selected. It then cycles through each column looking for the user-defined string. The code works just fine when a specific column heading is selected from the listbox so I dont understand why the use of multiple column headings in a SQL/OR or statement doesnt also work.
Code:
If cbChooseCol.SelectedItem = ("[Select All]" ) Then
Dim field1, criterial As String
field1 = "PartMaster."
criterial = txtCriterial.Text
criterial.StartsWith("" )
.Clear()
.DefaultView.RowFilter = _
"SELECT Description Like %" & txtCriterial.Text & "%" Or _
"[Vendor] like %" & txtCriterial.Text & "%" Or _
"Notes like %" & txtCriterial.Text & "%" Or _
code continues until ..........
"from PartMaster WHERE ," & _
"(" & field1 & " = " & criterial & " )"
Last edited by a moderator: