Solved

Acces Query Window Updates But VBA execute of same SQL Statement doesn't update WHY?

Posted on 2016-09-12
2
23 Views
Last Modified: 2016-09-13
Why is it that when i copy the following sql statement from the immediate window and paste it into the query window and hit run query, the query will update my table. But the this same query will not update my table if i use the currentproject.connection.execute method.

"UPDATE CreditCardDetail SET CreditCardDetail.Vendor = 'ZFUEL', CreditCardDetail.GlAccount = '6110.00' WHERE (((CreditCardDetail.ImportDate) Is Null) AND ((CreditCardDetail.CompanyName)='PBI') AND ((CreditCardDetail.YearMonth)='2016_08') AND ((CreditCardDetail.CreditCard)='Amex') AND ((CreditCardDetail.Description) Like '*7-ELEVEN*' Or (CreditCardDetail.Description) Like '*CHEVRON*' Or (CreditCardDetail.Description) Like '*CITY EXPRESS*' Or (CreditCardDetail.Description) Like '*CIRCLE K*' Or (CreditCardDetail.Description) Like '*MAVERIK*' Or (CreditCardDetail.Description) Like '*PILOT*' Or (CreditCardDetail.Description) Like '*REBEL*' Or (CreditCardDetail.Description) Like '*SHELL OIL*' Or (CreditCardDetail.Description) Like '*TEXACO*' Or (CreditCardDetail.Description) Like '*UNION 76*'));"
0
Comment
Question by:jb702
2 Comments
 
LVL 13

Accepted Solution

by:
John Tsioumpris earned 500 total points
ID: 41795544
how about running
Docmd.RunSQL yourSQL

Open in new window


I formatted your query in order to be easier to read
UPDATE CreditCardDetail
SET CreditCardDetail.Vendor = 'ZFUEL'
	,CreditCardDetail.GlAccount = '6110.00'
WHERE (
		((CreditCardDetail.ImportDate) IS NULL)
		AND ((CreditCardDetail.CompanyName) = 'PBI')
		AND ((CreditCardDetail.YearMonth) = '2016_08')
		AND ((CreditCardDetail.CreditCard) = 'Amex')
		AND (
			(CreditCardDetail.Description) LIKE '*7-ELEVEN*'
			OR (CreditCardDetail.Description) LIKE '*CHEVRON*'
			OR (CreditCardDetail.Description) LIKE '*CITY EXPRESS*'
			OR (CreditCardDetail.Description) LIKE '*CIRCLE K*'
			OR (CreditCardDetail.Description) LIKE '*MAVERIK*'
			OR (CreditCardDetail.Description) LIKE '*PILOT*'
			OR (CreditCardDetail.Description) LIKE '*REBEL*'
			OR (CreditCardDetail.Description) LIKE '*SHELL OIL*'
			OR (CreditCardDetail.Description) LIKE '*TEXACO*'
			OR (CreditCardDetail.Description) LIKE '*UNION 76*'
			)
		);

Open in new window

0
 

Author Comment

by:jb702
ID: 41796055
Yes, that worked, but why?. Ive used the currentproject.connection.execute method for years and never had a problem. What's the difference between the two.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

The code described here does no longer work. Please see replacement Article: http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/A_3887-Getting-your-EE-Ranking-statistics-in-Excel-The-Next-Generation.html (http…
Being an active EE Expert means to get a lot of (E)EMail, as you certainly know. If you are using Outlook, I'll show you how to minimize your inbox contents without losing anything – even improve the experience by changing the Subject line to facili…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now