access tempvars 宏_TempVars的,并获得2003

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.

解决方案

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.

Option Compare Database

Option Explicit

#Const Aversion = "2007" 'conditional compiler constant '

Public Sub HelloWorld()

Dim strWho As String

strWho = "World"

#If Aversion = "2007" Then

'* your 2007 feature code here *'

strWho = UCase(strWho)

#End If

'Aversion 2003 -> Hello World '

'Aversion 2007 -> Hello WORLD '

Debug.Print "Hello " & strWho

End Sub

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值