Solved

Ms access SQL Select Like Query Error.

Posted on 2008-10-18
6
834 Views
Last Modified: 2013-11-28
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
0
Comment
Question by:applefruit
  • 3
  • 2
6 Comments
 
LVL 2

Expert Comment

by:Benji_
ID: 22747573
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
 

Author Comment

by:applefruit
ID: 22747594
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
 

Author Comment

by:applefruit
ID: 22747595
This is the site i took reference from http://support.microsoft.com/kb/294954,
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 22747596
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
 
LVL 2

Expert Comment

by:Benji_
ID: 22747604
angel got there before me:D
0
 

Author Comment

by:applefruit
ID: 22747656
THANKS
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now