Hello all...
I wrote an Access 2003 app that's been running OK for years. Now I'm trying to run it in our new server (Windows Server 2008) which has Access 2007. The app seems to run fine, except that when the VB code tries to run a query (using SQL syntax) I'll get error messages ("Type Mismatch", or it will ask for a field that's already there). Oddly, I cut-and-pasted the SQL line from the code, and created a new query with it, and the query runs just fine! So the problem is specific to running the query from VB... :-\
The code goes something like this (I simplified the SQL line a lot):
Dim qry As Recordset, sql As String
sql = "SELECT tblPremises.Licensees, tblMunicipalities.MunicipalityName, tblReps.Sales_rep_desc WHERE (((tblReps.Sales_rep_desc)=" & Chr(34) & Forms!frmPremiseSelection!cmbRep & Chr(34) & "));"
Set qry = CurrentDb().OpenRecordset(sql) <== Error #13 (Type Mismatch) occurs here
As I said, If I cut and paste the sql line and create a query, runs fine... So it's not a problem w/ the SQL syntax, or any "true" type mismatch....
I checked the VB References and I have checked all the same ones I have checked in Access 2003... What could be causing the queries to fail if ran them from VB in Access 2007...?? Please help...!

I wrote an Access 2003 app that's been running OK for years. Now I'm trying to run it in our new server (Windows Server 2008) which has Access 2007. The app seems to run fine, except that when the VB code tries to run a query (using SQL syntax) I'll get error messages ("Type Mismatch", or it will ask for a field that's already there). Oddly, I cut-and-pasted the SQL line from the code, and created a new query with it, and the query runs just fine! So the problem is specific to running the query from VB... :-\
The code goes something like this (I simplified the SQL line a lot):
Dim qry As Recordset, sql As String
sql = "SELECT tblPremises.Licensees, tblMunicipalities.MunicipalityName, tblReps.Sales_rep_desc WHERE (((tblReps.Sales_rep_desc)=" & Chr(34) & Forms!frmPremiseSelection!cmbRep & Chr(34) & "));"
Set qry = CurrentDb().OpenRecordset(sql) <== Error #13 (Type Mismatch) occurs here
As I said, If I cut and paste the sql line and create a query, runs fine... So it's not a problem w/ the SQL syntax, or any "true" type mismatch....
I checked the VB References and I have checked all the same ones I have checked in Access 2003... What could be causing the queries to fail if ran them from VB in Access 2007...?? Please help...!
