Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 12th, 2010, 04:12 PM
Authorized User
 
Join Date: Sep 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default General ODBC error

the debugger is coming up at the .Refresh BackgroundQuery:=False line which generally means that something is wong with my sql syntax. However, I know this is not the case.
The macro works fine for almost all cases except the most simple.
I have the user select salespeople, categories, and a date range. If they select all users and all categories, the only thing that goes into the sql statement is the date range so the sql statement ends up being:
Code:
SELECT * FROM MonthInvoices WHERE (`Invoice Date`>=20091201 And `Invoice Date`<=20100112)
this statement generates the general ODBC error, while one like
Code:
SELECT * FROM MonthInvoices WHERE (`Invoice Date`>=20091201 And `Invoice Date`<=20100112) AND (Category='BANNER')
works just fine or even something much more complicated like
Code:
SELECT * FROM MonthInvoices WHERE (`Invoice Date`>=20091201 And `Invoice Date`<=20100112) AND (Trim(Salesperson)='CC      ') AND (Trim(Category)='ADJP  ') OR (`Invoice Date`>=20091201 And `Invoice Date`<=20100112) AND (Trim(Salesperson)='CC      ') AND (Trim(Category)='BANNER') OR (`Invoice Date`>=20091201 And `Invoice Date`<=20100112) AND (Trim(Salesperson)='CC      ') AND (Trim(Category)='BOND  ') OR (`Invoice Date`>=20091201 And `Invoice Date`<=20100112) AND (Trim(Salesperson)='DP      ') AND (Trim(Category)='ADJP  ') OR (`Invoice Date`>=20091201 And `Invoice Date`<=20100112) AND (Trim(Salesperson)='DP      ') AND (Trim(Category)='BANNER') OR (`Invoice Date`>=20091201 And `Invoice Date`<=20100112) AND (Trim(Salesperson)='DP      ') AND (Trim(Category)='BOND  ') OR (`Invoice Date`>=20091201 And `Invoice Date`<=20100112) AND (Trim(Salesperson)='FRU     ') AND (Trim(Category)='ADJP  ') OR (`Invoice Date`>=20091201 And `Invoice Date`<=20100112) AND (Trim(Salesperson)='FRU     ') AND (Trim(Category)='BANNER') OR (`Invoice Date`>=20091201 And `Invoice Date`<=20100112) AND (Trim(Salesperson)='FRU     ') AND (Trim(Category)='BOND  ')
works just as well


any idea why i might be getting this error? thank you in advance for your help
 
Old January 13th, 2010, 01:18 PM
Authorized User
 
Join Date: Sep 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well I figured out the problem.... now I just need to know how to fix it.

The problem: The program is erroring when it's asked to return lines where the value of a certain column is 0. I can make it work by editing my sql statement to omit those lines, but then my report is wrong. The same query works fine in access and ms query; it is only when it tries to write the lines to exel that the problem comes up. Is there some way I can work around this?

thank you!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Error code / General question Grafixx01 Access 6 April 20th, 2007 08:12 AM
ODBC Drivers error '8007000e' rtr1900 Classic ASP Databases 15 October 25th, 2006 04:03 AM
SoapException:General network error deeptisingh20 ASP.NET 1.0 and 1.1 Basics 0 September 12th, 2006 01:18 AM
Informix ODBC Error kapi.goel ASP.NET 1.0 and 1.1 Basics 0 May 12th, 2006 06:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.