Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / February 2008

Tip: Looking for answers? Try searching our database.

* in sql instruction

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gatarossi@ig.com.br - 25 Feb 2008 17:50 GMT
Dear all,

I'm trying to do a sql instruction to bring data from access, but I don
´t know why it doesn't work:

Dim xlsht3 As Excel.Worksheet
Dim crit_customer As String

Set xlsht3 = Sheets("by model")

If xlsht3.Cells(3, 5).Value = "1-ALL CUSTOMERS" Then
   crit_customer = "*"
Else
   crit_customer = xlsht3.Cells(3, 5)
End If

sql = "SELECT ........ "
sql = sql & "WHERE (Left([yyyymm],4))= '2007' "
sql = sql & "AND cad_buyer_bill.buyer_name_bill Like '" &
crit_customer & "' "

When I put any customer name, it works, but when I have "1-ALL
CUSTOMERS" it doesn´t work!!!!

What can I do to solve this problem????

Thanks in advance!!!!
John Bundy - 25 Feb 2008 21:04 GMT
do a messagebox and see what sql is when it is processing a *. if it looks
valid, output it to a cell and copy/paste it into access and run it, this if
this doesn't pull it, it should tell you why. If it does work then i don't
have a clue.
Signature

-John
Please rate when your question is answered to help us and others know what
is helpful.

> Dear all,
>
[quoted text clipped - 23 lines]
>
> Thanks in advance!!!!
gatarossi@ig.com.br - 26 Feb 2008 11:05 GMT
Dear John,

I did it: debug.print sql

Then I put this sql code in a access consult, and for my surprise it
works!!!

I don't know why it doesn't work with excel. I think that the *
doesn't work in SELECT consult!!!

Thanks in advance!!!

André.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.