Solved

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

Posted on 2016-09-12
2
36 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

832 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