Using Access 2003 I update a query dynamically and it works fine. Below is a snippet of the code.
In 2010 it fails on the first line. I'm using the development version of 2010. The error I get is:
Microsoft Access has stopped working
Windows can try to recover your information and restart the program
I tried replacing the first line with the actual SQL from the query. When I do that it fails on the last line where I try to update the query it the changed SQL. The if statement for txtContractor in the code does not execute in my test.
Something different with QueryDefs in 2010?
Code:
strSQLOrig = CurrentDb.QueryDefs("qryImportDocsFilter").sql
strSQL = Replace(strSQLOrig, "ExtMDB", "'" & ImportFile & "'")
If txtContractor = "Fluor" Then
strSQL = Replace(strSQL, "JEG Proj", "FLR Proj")
End If
CurrentDb.QueryDefs("qryImportDocsFilter").sql = strSQL
In 2010 it fails on the first line. I'm using the development version of 2010. The error I get is:
Microsoft Access has stopped working
Windows can try to recover your information and restart the program
I tried replacing the first line with the actual SQL from the query. When I do that it fails on the last line where I try to update the query it the changed SQL. The if statement for txtContractor in the code does not execute in my test.
Something different with QueryDefs in 2010?