wild card error "*" in sql script (1 Viewer)

hawkpig

Registered User.
Local time
Today, 14:38
Joined
Jun 5, 2007
Messages
10
Hi chaps

I am a little stumped here. I have created a simple SELECT sql script which works fine if I make the "WHERE" part of the query refer to a specific record, but if I use a wildcard, the process errors saying that no records are found even though I know there are records that meet the criteria.

Does anyone have any ideas or thoughts?

********************************

I am using access 2003 - the VBA editor is version 6.3

********************************
this works:

Dim MySql As String

MySql = MySql & " SELECT [CURRENT POLICY #]"
MySql = MySql & " FROM [C01 RENEWAL TABLE]"
MySql = MySql & " WHERE ([CURRENT POLICY #] LIKE 'COM002000')"
MySql = MySql & " order by [CURRENT POLICY #]"



********************************
this doesn't:

Dim MySql As String

MySql = MySql & " SELECT [CURRENT POLICY #]"
MySql = MySql & " FROM [C01 RENEWAL TABLE]"
MySql = MySql & " WHERE ([CURRENT POLICY #] LIKE 'COM*')"
MySql = MySql & " order by [CURRENT POLICY #]"
 
Last edited:

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 14:38
Joined
Sep 12, 2006
Messages
15,796
perhaps its not using the widcard properly

maybe its actually looking for a record called COM*

--------
try preparing a visual query, and see if the sql looks like what you had
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 06:38
Joined
Aug 30, 2003
Messages
36,146
What are you doing with the SQL string? If you're opening an ADO recordset, it wants % as the wildcard instead of *.
 

hawkpig

Registered User.
Local time
Today, 14:38
Joined
Jun 5, 2007
Messages
10
Hi Paul

That did the trick - you're a legend - thanks for your help

I'll ignore all the rude things people say about you on this forum - just kidding.

thanks again.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 06:38
Joined
Aug 30, 2003
Messages
36,146
Happy to help...and I ignore them too. :D
 

Users who are viewing this thread

Top Bottom