Ms access SQL Select Like Query Error.

Hi there,

I am have a slight problem with my Select LIKE statement. I have attached a screenshot for a better understanding.

I have tried following the advice on microsft's page, however it still does not work. Hope you can advice me on what should i do. Thanks.

My button's Code below:


Private Sub btnSearchByActors_Click()
 
    Me.listboxMovieListing.RowSource = "SELECT Movies.MovieId, Movies.Title, Movies.UnitRentalFee, Movies.Ratings, Movies.Qty FROM Movies WHERE Movies.Actors LIKE " & "*" & Forms!fmMoviesAvailableForRent!tbxMovieActors & " * "
    Me.listboxMovieListing.Requery
    
End Sub

Open in new window

select-like-screenshot.jpg
applefruitAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I agree, you are missing the string quotes for the query.
you also had a space before the second *.

Private Sub btnSearchByActors_Click()
 
    Me.listboxMovieListing.RowSource = "SELECT Movies.MovieId, Movies.Title, Movies.UnitRentalFee, Movies.Ratings, Movies.Qty FROM Movies WHERE Movies.Actors LIKE '*" & Forms!fmMoviesAvailableForRent!tbxMovieActors & "*' "
    Me.listboxMovieListing.Requery
    
End Sub

Open in new window

0
 
Benji_Commented:
i belive you are missing a ' from each side of the statement,

eg select field1,field2 from table where  field1 like 'result%'

% as a wildcard
0
 
applefruitAuthor Commented:
Hi i dont really understand what you mean. Can you maybe show me an example using my codes?

This is the site that i took reference from, they said that the wild card should be * instead of % correct?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
applefruitAuthor Commented:
This is the site i took reference from http://support.microsoft.com/kb/294954,
0
 
Benji_Commented:
angel got there before me:D
0
 
applefruitAuthor Commented:
THANKS
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.