simple like clause problem in ADO

S

susiedba

ok; this query works GREAT when I paste it into a new MDB query.
but it is 'too loose' when I run it as a ADO recordset... it is 'too
loose' because it catches a query named ''

Does anyone have a simple answer for this?
Is it the simple difference between a single quote and a double-quote?


This kinda stuff has caught me up quite a bit recently... I mean; this
has caught me up the last 4-5 times I've tried MDB and it
just drives me crazy.


Select [name]
from msysobjects
where LEFT([name], 4) = 'QF01' AND [name] not like '*template*'
ORDER BY [NAME]


this is my whole code:


Dim rstF As New ADODB.Recordset
rstF.Open "Select [name] from msysobjects where LEFT([name], 4) = "

& S_FlashLike & " AND [name] not like '*template*' ORDER BY [NAME]",
CurrentProject.Connection
Do Until rstF.EOF
FlashThisQuery (rstF!Name)
rstF.MoveNext
Loop
Set rstF = Nothing


?S_FlashLike
'QF01'


?rstF!Name
QF01_CT_QAttribute_TEMPLATE
 
D

Douglas J. Steele

ADO uses % as the wildcard, not *.

Also, you don't have either single or double quotes around the name value
for which you're searching.

You need:

rstF.Open "Select [name] from msysobjects where LEFT([name], 4) = '" & _
S_FlashLike & "' AND [name] not like '%template%' ORDER BY [NAME]", _
CurrentProject.Connection
 
S

susiedba

WOW.

Thanks douglas.... no wonder MDB has always given me troubles :)

-Aaron


ADO uses % as the wildcard, not *.

Also, you don't have either single or double quotes around the name value
for which you're searching.

You need:

rstF.Open "Select [name] from msysobjects where LEFT([name], 4) = '" & _
S_FlashLike & "' AND [name] not like '%template%' ORDER BY [NAME]", _
CurrentProject.Connection


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


ok; this query works GREAT when I paste it into a new MDB query.
but it is 'too loose' when I run it as a ADO recordset... it is 'too
loose' because it catches a query named ''

Does anyone have a simple answer for this?
Is it the simple difference between a single quote and a double-quote?


This kinda stuff has caught me up quite a bit recently... I mean; this
has caught me up the last 4-5 times I've tried MDB and it
just drives me crazy.


Select [name]
from msysobjects
where LEFT([name], 4) = 'QF01' AND [name] not like '*template*'
ORDER BY [NAME]


this is my whole code:


Dim rstF As New ADODB.Recordset
rstF.Open "Select [name] from msysobjects where LEFT([name], 4) = "

& S_FlashLike & " AND [name] not like '*template*' ORDER BY [NAME]",
CurrentProject.Connection
Do Until rstF.EOF
FlashThisQuery (rstF!Name)
rstF.MoveNext
Loop
Set rstF = Nothing


?S_FlashLike
'QF01'


?rstF!Name
QF01_CT_QAttribute_TEMPLATE
 

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