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?

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 .
Be a part of the DaniWeb community

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