Problem running basic SQL in excel...

R

Rone

I'm having a bit of difficulty running a basic SQL query using excel. I'm
connected to a Microsoft Access.

Here is the SQL I am using:

SELECT count(*) FROM 3_REPORT WHERE CallType = 3 AND PartyIDName Like '*fax*';

If I run this SQL inside Access it will run just fine and return the count
of rows just like I want. However, when I put it into the excel VBA it
returns "0"
as the row count, but I know there are 192 rows. Is there a problem with the
"Like" clause and the VBA? It doesn't seem to matter what text I put in the
"like clause" it always returns zero, even when I know there should be rows
returned.

I'm not sure where to go from here. Any help will be appreciated.

Thanks.
 
M

MH

If you are using ADO (rather than DAO) then the wildcard character you need
to use is not * but %, so:

SELECT count(*) FROM 3_REPORT WHERE CallType = 3 AND PartyIDName Like
'%fax%';

It always helps if you paste the code though!

MH
 
R

Rone

Thanks MH. You were exactly right. It works fine now. I'm using ADODB and
thought the syntax was supposed to be exactly the same as if I was in access.

Lesson learned.
 

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