Rohit Mishra
Rohit Mishra

Reputation: 19

Get records with blank field value using LIKE statement

I am using a filter criteria to pull records where my table shows dynamic search results based on the input text. below is the code I am using -

Me.Bookbindingsource.Filter = *Book_Author LIKE '*" & TextBox.Text & "*'"

This field can be blank. When form loads, I want it to display all the records, but only those records are displayed which have atleast one character in the Author field.

Upvotes: 0

Views: 707

Answers (2)

I A Khan
I A Khan

Reputation: 8859

Add where clause

where Book_Author LIKE '*" & TextBox.Text & "*' or Book_Author = ''

and if you have already other where clause then add

AND ( Book_Author LIKE '*" & TextBox.Text & "*' or Book_Author = '')

Upvotes: 0

Pரதீப்
Pரதீப்

Reputation: 93734

Try this where clause. Use OR condition to accept the empty string

where (Book_Author LIKE '*" & TextBox.Text & "*' or Book_Author = '')

Upvotes: 1

Related Questions