I am getting an error code (3146: ODBC-call failed - Invalid cursor state (#0) on my local machine using Microsoft Access 365, but it works in our remote desktop environment using 2016 Access Professional Plus. We are using the same drivers in both environments: SQL Server Native Client 11.0
HTML Code:
Sub GMSImport(StartDate As Date, EndDate As Date)Dim SqlStr As StringDim db As DAO.DatabaseSet db = CurrentDb()
'Builds query string for stored procedureSqlStr = "EXEC dbo.upRpt_WeeklyDealsReport @BeginDate = '" & Format(StartDate, "yyyy-mm-dd") & "' ," & _ " @EndDate = '" & Format(EndDate, "yyyy-mm-dd") & "' ," & _ " @RegionType_Short_List = 'CA~GC~MC~MW~SW~WE~NE' ," & _ " @IncludeBulletDeals = 0 ," & _ " @FormatType = 'spgexporttype'"
db.QueryDefs("ptqry_DataExport").sql = SqlStr 'sets the parameters for the stored procedure
DoCmd.SetWarnings FalseDoCmd.OpenQuery "qryImportGMSData" 'Creates tempTable from import
DoCmd.RunSQL "ALTER TABLE temp_GMSImport ADD COLUMN Selected BIT" 'Add Selected Column to temp tableDoCmd.RunSQL "ALTER TABLE temp_GMSImport ADD COLUMN dvsValuationDef_ID INT" 'Adds Valuation Def Column to temp tableDoCmd.RunSQL "UPDATE temp_GMSImport SET temp_GMSImport.Selected = -1;" 'Sets all Selected field to TRUE
DoCmd.SetWarnings True
End Sub
The error occurs on this line of code:
HTML Code:
DoCmd.OpenQuery "qryImportGMSData" 'Creates tempTable from import
I am using a passthrough query to execute a stored procedure, and use the results in a make table query. I can manually execute the passthrough query against the SQL Server db, but when the code runs qryImportGMSData (make table query) I get the ODBC call error.
Any idea why there is a difference between Office 365 and Professional Plus 2016?
Thanks,
Brent