Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why don't the Like work in the query?

Status
Not open for further replies.

nkamp

Programmer
Jan 19, 2004
35
0
0
NL
Hallo,

The following what I do not understand:

Code:
  Set cmd = New ADODB.Command
  Set cmd.ActiveConnection = CurrentProject.Connection
  cmd.CommandType = adCmdText

  cmd.CommandText = "SELECT par1 FROM tblparameters Where tblparameters.gcnf = 'XMLexp' AND ((tblparameters.ccnf) Like 'ExpTijd*')"
  Set rec = cmd.Execute()
  
  Do While rec.EOF = False
    MsgBox rec("par1").Value
    rec.MoveNext
  Loop

I don't get any result back. If I changed it likt the following:
tblparameters.ccnf = 'ExpTijd1' , in the query, I get one record back.
So my conclusion the query is right but the Like doesn't work in these circumstances?

thanks in advance.

Nico
 
nkamp,
Instead of using [tt]Command[/tt] object, try using a [tt]Recordset[/tt] object.
Code:
  Set rst = New ADODB.Recordset

  rst.Open "SELECT par1 FROM tblparameters " & _
  "Where tblparameters.gcnf = 'XMLexp' AND " & _
  "((tblparameters.ccnf) Like 'ExpTijd*')", & _               
  CurrentProject.Connection
  
  Do While rst.EOF = False
    MsgBox rst("par1").Value
    rst.MoveNext
  Loop

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
what back end are you connecting to?

if it's sql server, then the wildcard character is %, not *

--------------------
Procrastinate Now!
 
I have found the problem. It must the "%" sign instead of "*" because the application which I have to maintain uses the DAO microsoft rubish specific wildcards.

Thanks anyway.

Nico
 
O sorry, I see now that Crowly also has mentioned this.


Nico
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top