Solved

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

Posted on 2016-09-12
2
41 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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.​
Use Windows Task Scheduler to print a Word document weekly so your printer ink won't dry out.
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…

742 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