filter button syntax error during execution

  • Thread starter Thread starter Ravi Kumar12233
  • Start date Start date
R

Ravi Kumar12233

Guest
Hello all ,
I have a text box and a filter button to filter the record in my data-grid box , but apparently it is not working and showing error message as

An error Occurred : Syntax error:Missing Operand After "%h%" operator.

And this is my code , please help me how to solve this:

Private Sub AlertWarningMessage()
'Do not allow search while addign record
MsgBox("The Search Function Is Disabled While Adding New Record",
MsgBoxStyle.OkOnly Or MsgBoxStyle.Exclamation, "Find Record")
End Sub

Private Sub SearchButton_Click(sender As Object, e As EventArgs) Handles SearchButton.Click
ToolStripStatusLabel1.Text = "Status"
If IsAddNewRecordInProgress = True Then
AlertWarningMessage()
Exit Sub
End If
If Not String.IsNullOrEmpty(KeywordTextBox.Text) Then
SearchInAccessDatabase(KeywordTextBox.Text.Replace("'", "''"))
Else
RefreshData()
Return
End If

End Sub

Private Sub SearchInAccessDatabase(ByVal stringKeyword As String,
Optional stringFilter As String = "")
Try
stringFilter = "(Convert(ID, 'System.String') LIKE '" & stringKeyword & "')" &
" OR ([Size in mg] LIKE '%" & stringKeyword & "%')" &
" OR ([Die head number] LIKE '%" & stringKeyword & "%')" &
" OR (Observations '%" & stringKeyword & "%')" &
" OR (Inspector LIKE '%" & stringKeyword & "%')"
MSdiesBindingSource.Filter = stringFilter
If MSdiesBindingSource.Count < 1 Then
MsgBox("-->>" & stringKeyword & "<<--" & vbNewLine & Environment.NewLine &
"The serach item not found", MsgBoxStyle.OkOnly Or MsgBoxStyle.Information,
"Find Record")
RefreshData()
End If


Catch ex As Exception
MessageBox.Show("An Error Occured: " & ex.Message.ToString(),
"Find Record", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try

End Sub

Continue reading...
 
Back
Top