RTE 3075 in LIKE SQL statment (Word2003)

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15640
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

RTE 3075 in LIKE SQL statment (Word2003)

Post by ChrisGreaves »

Untitled.jpg
I am ten-years-rusted-out on using SQL statements to filter records; I seek help.
My VBA code (attached) is written in Word2003/VBA and accesses an MSAccess2003 MDB query called "qryDateLastPlayed".

This is a jukebox player that tries to play "stale" tracks that have not been played in a long time, with an option to select from those, only tracks whose Fullname contains a supplied string (in my example I am looking for "organ" music)
From the Debug Window

Code: Select all

?strselect
SELECT * from qryDateLastPlayedALL ORDER BY DateLastPlayed WHERE FullName LIKE 'organ'
I tried embracing the string organ in single quotes, and then in double-quotes.

FWIW the second SELECT statement (without a LIKE operator) executes perfectly.

Thanks for any nudges in the right direction.
Chris
You do not have the required permissions to view the files attached to this post.
There's nothing heavier than an empty water bottle

snb
4StarLounger
Posts: 584
Joined: 14 Nov 2012, 16:06

Re: RTE 3075 in LIKE SQL statment (Word2003)

Post by snb »

Try:

strSelect = "SELECT * from qryDateLastPlayed WHERE FullName LIKE """ & strSearch & """ ORDER BY DateLastPlayed"

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15640
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: RTE 3075 in LIKE SQL statment (Word2003)

Post by ChrisGreaves »

snb wrote:
10 Aug 2023, 16:25
strSelect = "SELECT * from qryDateLastPlayed WHERE FullName LIKE """ & strSearch & """ ORDER BY DateLastPlayed"
Thank you snb :clapping:

Rather than "Organ", I now use "*Organ*", which works. Also puzzles me, but I can fine-tune that later.
For now I can load a set of tracks to a maximum duration (program cycle length) with a specific type of music appearing first, followed by "other stuff" to fill out the cycle.
Thanks again!
There's nothing heavier than an empty water bottle