Im creating a filter/search for a datagridview in VB. I have a two comboboxes and one textbox. combobox1 selects a field, combobox 2 selects criteria, textbox is for values. After I select my field and criteria and enter in my value, I hit a Go button and run the following code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.TblSpeedStudyBindingSource.Filter = "select * from tblSpeedStudy where " & "'" & ComboBox1.SelectedItem & "' " & "'" & ComboBox2.SelectedItem & "' " & TextBox1.Text & " "
    End Sub

I get a syntax error: Missing operand after 'tblSpeedStudy' operator.

Anyone know what I'm doing wrong?

7 Years
Discussion Span
Last Post by pritesh2010

try this way you doing write but error is over here

"Select * from [tblSpeedStudy] Where [write codition] like/='" & ComboBox1.SelectedItem & "' and [write codition] like/='" & ComboBox2.SelectedItem & "' and [write codition] like/= '" & TextBox1.Text & "'"

// when you want search then we write 
Select * from table Where [Column] like/= value 
// at your condition you didn't defined a column .
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.