I have a database that is used in a mixed 2003, 2007 environment. I have some minor functionality that uses 2007's new TempVars feature. If it is a 2003 user, it isn't a problem for them to not have those features.
How do I write my code so that it will compile and run on Access 2003. I have tried on error resume next
but this doesn't work for compile time errors.
Here is a nice summary about using VBA built-in compiler constants.
#If VBA7 Then
could help you to differentiate Office 2010 only code. Unfortunately it does not apply to Office 2007.If your application will be used with Access 2003, seems to me you should exclude features 2003 doesn't support.
However, if you must have Tempvars, see whether a conditional compiler constant approach would make it work for you.
Check Access' Help for more information about #Const and #If.
I haven't tested this, but I think it could work. You might need two copies of your database: YourDb2003.mdb; and YourDb2007.mdb. In YourDb2003.mdb use "2003" as the compiler constant, and "2007" in YourDb2007.mdb.