I created a query in Access and it runs fine. I copied the sql because I want to run it from Excel. However, I can't get it to run. Below is the sql code I'm using. When I kick it off, I get a "No Value provided for one or more required parameters". The connectionstring and data source have been defined and are correct.
Any suggestions on what is causing the error? Thanks in advance.
vsql = "SELECT HeaderFile.FileDate, Mid(HeaderFile![12DIGITBILLING#],1,2), Mid(HeaderFile![12DIGITBILLING#],3,1), " & _
"HeaderFile!BFSUnit, HeaderFile.BTName, HeaderFile.Address, HeaderFile.CityStateZip,HeaderFile.Loc, HeaderFile.AcctNo, " & _
"HeaderFile.Invoice, HeaderFile.WorkDate, HeaderFile.STName, HeaderFile.STAddress, HeaderFile.STCityStateZip, HeaderFile.StoreNo, HeaderFile.StoreType, " & _
"HeaderFile.StoreCity , HeaderFile.StoreState, HeaderFile.StoreWorkDate, HeaderFile.BilledDate, HeaderFile.COMMENTS, HeaderFile.PO, " & _
"HeaderFile.VEHICLENUM, HeaderFile.GROUPNUM,
HeaderFile.[12DIGITBILLING#], HeaderFile.[FSNE-ID], HeaderFile.STORENAME, " & _
"HeaderFile.ADDRESS1, HeaderFile.ADDRESS2, HeaderFile.PHONENUMBER, HeaderFile.DRIVER, HeaderFile.MILEAGE, HeaderFile.VIN, " & _
"HeaderFile.MAKE , HeaderFile.MODEL, HeaderFile.YEAR, HeaderFile.TRANS, HeaderFile.LICENSE, HeaderFile.SALE, " & _
"HeaderFile.TIRE, HeaderFile.[Tax Amt], HeaderFile.InvExcise, HeaderFile.InvAmt, HeaderFile.DiscAmt, HeaderFile.TruckTire, " & _
"HeaderFile.DueDate , HeaderFile.DAmt, HeaderFile.Bonus, DetailFile.LineNo, DetailFile.Units, " & _
"DetailFile.Article, DetailFile.Descr, DetailFile.Price, DetailFile.PerUnit, DetailFile.Class, DetailFile.TaxCode, DetailFile.ExAmt, DetailFile.RUnits, DetailFile.Factor, " & _
"DetailFile.RPrice , DetailFile.DEAmt, DetailFile.TDescr, DetailFile.TAmt, DetailFile.TEAmt " & _
" FROM HeaderFile INNER JOIN DetailFile ON (HeaderFile.InvoiceNo = DetailFile.InvoiceNo) AND (HeaderFile.AcctNo = DetailFile.AcctNo) AND (HeaderFile.Loc = DetailFile.Loc)" & _
" WHERE HeaderFile.AcctNo = ""00020017"" "
Call Recordset.Open(vsql, ConnectionString, adOpenForwardOnly, adLockReadOnly, CommandTypeEnum.adCmdText)
Any suggestions on what is causing the error? Thanks in advance.
vsql = "SELECT HeaderFile.FileDate, Mid(HeaderFile![12DIGITBILLING#],1,2), Mid(HeaderFile![12DIGITBILLING#],3,1), " & _
"HeaderFile!BFSUnit, HeaderFile.BTName, HeaderFile.Address, HeaderFile.CityStateZip,HeaderFile.Loc, HeaderFile.AcctNo, " & _
"HeaderFile.Invoice, HeaderFile.WorkDate, HeaderFile.STName, HeaderFile.STAddress, HeaderFile.STCityStateZip, HeaderFile.StoreNo, HeaderFile.StoreType, " & _
"HeaderFile.StoreCity , HeaderFile.StoreState, HeaderFile.StoreWorkDate, HeaderFile.BilledDate, HeaderFile.COMMENTS, HeaderFile.PO, " & _
"HeaderFile.VEHICLENUM, HeaderFile.GROUPNUM,
HeaderFile.[12DIGITBILLING#], HeaderFile.[FSNE-ID], HeaderFile.STORENAME, " & _
"HeaderFile.ADDRESS1, HeaderFile.ADDRESS2, HeaderFile.PHONENUMBER, HeaderFile.DRIVER, HeaderFile.MILEAGE, HeaderFile.VIN, " & _
"HeaderFile.MAKE , HeaderFile.MODEL, HeaderFile.YEAR, HeaderFile.TRANS, HeaderFile.LICENSE, HeaderFile.SALE, " & _
"HeaderFile.TIRE, HeaderFile.[Tax Amt], HeaderFile.InvExcise, HeaderFile.InvAmt, HeaderFile.DiscAmt, HeaderFile.TruckTire, " & _
"HeaderFile.DueDate , HeaderFile.DAmt, HeaderFile.Bonus, DetailFile.LineNo, DetailFile.Units, " & _
"DetailFile.Article, DetailFile.Descr, DetailFile.Price, DetailFile.PerUnit, DetailFile.Class, DetailFile.TaxCode, DetailFile.ExAmt, DetailFile.RUnits, DetailFile.Factor, " & _
"DetailFile.RPrice , DetailFile.DEAmt, DetailFile.TDescr, DetailFile.TAmt, DetailFile.TEAmt " & _
" FROM HeaderFile INNER JOIN DetailFile ON (HeaderFile.InvoiceNo = DetailFile.InvoiceNo) AND (HeaderFile.AcctNo = DetailFile.AcctNo) AND (HeaderFile.Loc = DetailFile.Loc)" & _
" WHERE HeaderFile.AcctNo = ""00020017"" "
Call Recordset.Open(vsql, ConnectionString, adOpenForwardOnly, adLockReadOnly, CommandTypeEnum.adCmdText)