troubleshooting Question

i try to run a sql statement in vba in access 2010 and i get an error "A RunSQL action requires an argument consisting of an SQL"

Avatar of bill201
bill201 asked on
DatabasesMicrosoft AccessSQL
9 Comments1 Solution880 ViewsLast Modified:
i tried to run some sql code and it's don't worked from vba but when i put the same string in regular query its worked why it this and if there is some solution to run this sql statement from vba

and this is my  error message:
Run-time error '2342':
A RunSQL action requires an argument consisting of an SQL
Dim CusInf As Integer
Dim DateInv As Date
Dim SqlStr As String
CusInf = 3
DateInv = DateSerial(2010, 8, 25)
SqlStr = "SELECT  CustomerID,InvoiceID, InvoiceDate, Product, Qty, Price, Total, Maam, TotalIncludeTaxb "
SqlStr = SqlStr & "FROM [;DATABASE=C:\Users\books\sample.mdb ;PWD=121].[invoices1]"
SqlStr = SqlStr & " WHERE CustomerID=" & CusInf & " AND InvoiceDate<#" & DateInv & "#"

DoCmd.RunSQL SqlStr

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros