Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Problem running basic SQL in excel...

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.
--
Rone
  #2   Report Post  
Posted to microsoft.public.excel.programming
MH MH is offline
external usenet poster
 
Posts: 30
Default Problem running basic SQL in excel...

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



"Rone" wrote in message
...
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.
--
Rone



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Problem running basic SQL in excel...

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.
--
Rone


"MH" wrote:

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



"Rone" wrote in message
...
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.
--
Rone




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 Basic Filters Problem Simon Whale Setting up and Configuration of Excel 1 October 15th 09 05:27 PM
Formatting problem with basic excel sheet TheWanderer New Users to Excel 4 August 13th 08 12:20 AM
Basic problem with EXCEL 2002 [email protected] Excel Discussion (Misc queries) 1 October 24th 06 12:16 AM
Basic Excel macro problem with outlook mike0021 Excel Programming 4 May 24th 04 09:41 PM
Stopping Excel after running visual basic in Access Bill McCaleb Excel Programming 4 April 4th 04 02:20 AM


All times are GMT +1. The time now is 12:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"