select where "..." is found in the in the field...

M

Mark Kubicki

I want to modify the below code to select all records where
[forms]![frmSpec].[Source] is contained anywhere in the [OptLamp.Source]
field

so let's say
[forms]![frmSpec].[[Source] = "fluorescent"
and in table OptLamp there are records with "fluorescent", "compact
fluorescent", "self-ballasted fluorescent'"... in the [OptLamp.source]
field,
all of those records should be returned

if
[forms]![frmSpec].[[Source] = "compact fluorescent"
then only the record in OptLamp with "compact fluorescent"... in
[OptLamp.source] would be returned

currently only exact matches are returned... (which is what I initially
thought I wanted...)

I suspect this is a very simple issue to deal with, but when you're a
self-taught newbie...
Many thanks in advance,
mark


SELECT OptLamp.Options
FROM OptLamp
WHERE (((OptLamp.manufacturer)=[forms]![frmSpec].[cboLamp1Manufacturer])
AND ((OptLamp.source)=[forms]![frmSpec].[Source]))
ORDER BY OptLamp.Options;
 
L

Lars Brownies

Try:

AND ((OptLamp.source)= Like "*" & [forms]![frmSpec].[Source] & "*"))

Lars
 
J

John W. Vinson

Try:

AND ((OptLamp.source)= Like "*" & [forms]![frmSpec].[Source] & "*"))

Lars

Lars, didn't you mean

((OptLamp.source) Like "*" & [forms]![frmSpec].[Source] & "*"))

instead? The = operator and the Like operator are two alternative choices, and
should not be used together.
 
L

Lars Brownies

Oops, typo. You're right.
Lars

John W. Vinson said:
Try:

AND ((OptLamp.source)= Like "*" & [forms]![frmSpec].[Source] & "*"))

Lars

Lars, didn't you mean

((OptLamp.source) Like "*" & [forms]![frmSpec].[Source] & "*"))

instead? The = operator and the Like operator are two alternative choices,
and
should not be used together.
 
M

Mark Kubicki

thanks (both of you !!)


Lars Brownies said:
Oops, typo. You're right.
Lars

John W. Vinson said:
Try:

AND ((OptLamp.source)= Like "*" & [forms]![frmSpec].[Source] & "*"))

Lars

Lars, didn't you mean

((OptLamp.source) Like "*" & [forms]![frmSpec].[Source] & "*"))

instead? The = operator and the Like operator are two alternative
choices, and
should not be used together.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top