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?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Guy Hengel [angelIII / a3]Connect With a Mentor 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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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
All Courses

From novice to tech pro — start learning today.