A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

"LIKE" query problem...



 
 
Thread Tools Display Modes
  #1  
Old July 7th, 2005, 08:48 AM
AlexT
external usenet poster
 
Posts: n/a
Default "LIKE" query problem...

Folks

I'm having a rather strange problem with a query to an Access file
from Excel.

My query looks like

SELECT qLookups.lkSubkey, qLookups.lkValue FROM qLookups WHERE
(qINTL.lkSubkey LIKE 'Test*' )

And is spposed to return all values from qLookups where lkSubkey start
with "Test".

Now that query works exactly as expected within Access.

I also want to use it from Excel through ADO. Altough no error is
reported the query doesn't return any data.

Now the interesting part is that if I remove the LIKE clause it does
work (returning obviously all records).

My code looks like

' Create the recordset object used to load the results
Set rstProds = New ADODB.Recordset

' ...and opens the recordset
' On Error Resume Next
rstProds.Open prmTheQuery, cnnMyDb

then later does a GetRows() on the recordset


Any idea ? Must say that I am baffled...

Regards

--alexT

  #2  
Old July 7th, 2005, 09:02 AM
Van T. Dinh
external usenet poster
 
Posts: n/a
Default

In ADO, the equivalent of the wild-card "*" is "%".

HTH
Van T. Dinh
MVP (Access)



"AlexT" wrote in message
oups.com...
Folks

I'm having a rather strange problem with a query to an Access file
from Excel.

My query looks like

SELECT qLookups.lkSubkey, qLookups.lkValue FROM qLookups WHERE
(qINTL.lkSubkey LIKE 'Test*' )

And is spposed to return all values from qLookups where lkSubkey start
with "Test".

Now that query works exactly as expected within Access.

I also want to use it from Excel through ADO. Altough no error is
reported the query doesn't return any data.

Now the interesting part is that if I remove the LIKE clause it does
work (returning obviously all records).

My code looks like

' Create the recordset object used to load the results
Set rstProds = New ADODB.Recordset

' ...and opens the recordset
' On Error Resume Next
rstProds.Open prmTheQuery, cnnMyDb

then later does a GetRows() on the recordset


Any idea ? Must say that I am baffled...

Regards

--alexT



  #3  
Old July 8th, 2005, 12:38 PM
AlexT
external usenet poster
 
Posts: n/a
Default

Wow

Thanks - just learned something !

--alexT

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Annual count queries on a field relative to a value that varies DA tobesus General Discussion 7 May 10th, 2005 07:50 AM
Problem with query and table joins Chuck Mueller Running & Setting Up Queries 1 February 18th, 2005 04:08 PM
adding 2 fields including null entries Jesse Running & Setting Up Queries 26 January 18th, 2005 05:31 PM
WORD XP mail-merge FAILS using ACCESS Query SueMackay Mailmerge 1 November 23rd, 2004 01:03 PM
Union Query Not Returning A Value Jeff G Running & Setting Up Queries 2 October 19th, 2004 05:47 PM


All times are GMT +1. The time now is 09:08 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.