收 藏 投 稿 繁 体 RSS 
站长吧-中国站长学习与交流的网站
首 页 运 营 学 院 建 站 论 坛
Web master8.net  
 网站运营  
  欢迎在本站发布信息,在线投递稿件请点这里。编辑QQ:4908220,欢迎联系交流。
业界动态 创业故事 推广研究 策划盈利 电子商务 企业平台
  站长工具
SEO查询 Whois查询 Pr查询 域名查询 IP查询 网页编辑器
 建站服务  
  如有建站意向,请尽快联系我们,以便安排时间... 建站服务 QQ4908220 QQ:4908220
作品展示 服务范围 服务流程 服务报价 联系方式 付款方式
文章正文  » 您的当前位置: 首页 >> 学院 >> 数据库 >> Access
设置只有管理员才能改变AllowBypassKey属性
  来源:互联网 | 时间:2005-10-04 | 浏览:   相关评论 | 报告错误 | 发布文章
【字号: | | 】 【背景色 杏仁黄 秋叶褐 胭脂红 芥末绿 天蓝 雪青 灰 银河白(默认色)

tmtony翻译:

在ACCESS的帮助文件中说明CreateProperty 方法的语法:

Set property = object.CreateProperty (name, type, value, DDL)
其实最后一个参数是这个解释的(部分描述):

DDL 可选. 一个变量(逻辑子类型) 指定这个属性是否为DDL对象. 缺少值为False. 如果设置为TRUE,除非他有 dbSecWriteDef 权限,用户就不能改变或删除这个属性
CreateProperty 是用来创建或设置 AllowBypassKey 属性如果这个属性设为TRUE, 那就可以禁用户近SHIFT键来禁止启动属性和AutoExec 宏. 然而,ACCESS帮助中提供的例子没有使用第四个 DDL 参数. 这意味着任何人都可以打开数据据然后用程序复位AllowBypassKey 属性.

所以,为了限制普通用户去改变这个属性,所以我们设置第四个参数为TRUE 。

为了对比,我们也同时列出了ACCESS本身的例子以便参照

" *********** Code Start ***********
Function ChangePropertyDdl(stPropName As String, _
PropType As DAO.DataTypeEnum, vPropVal As Variant) _
As Boolean
" Uses the DDL argument to create a property
" that only Admins can change.
"
" Current CreateProperty listing in Access help
" is flawed in that anyone who can open the db
" can reset properties, such as AllowBypassKey
"
On Error GoTo ChangePropertyDdl_Err

Dim db As DAO.Database
Dim prp As DAO.Property

Const conPropNotFoundError = 3270

Set db = CurrentDb
" Assuming the current property was created without
" using the DDL argument. Delete it so we can
" recreate it properly
db.Properties.Delete stPropName
Set prp = db.CreateProperty(stPropName, _
PropType, vPropVal, True)
db.Properties.Append prp

" If we made it this far, it worked!
ChangePropertyDdl = True

ChangePropertyDdl_Exit:
Set prp = Nothing
Set db = Nothing
Exit Function

ChangePropertyDdl_Err:
If Err.Number = conPropNotFoundError Then
" We can ignore when the prop does not exist
Resume Next
End If
Resume ChangePropertyDdl_Exit
End Function

帮助本身的例子
Function ChangeProperty(strPropName As String, _
varPropType As Variant, varPropValue As Variant) As Integer
" The current listing in Access help file which will
" let anyone who can open the db delete/reset any
" property created by using this function, since
" the call to CraeteProperty doesn"t use the DDL
" argument
"
Dim dbs As Database, prp As Property
Const conPropNotFoundError = 3270

Set dbs = CurrentDb
On Error GoTo Change_Err
dbs.Properties(strPropName) = varPropValue
ChangeProperty = True

Change_Bye:
Exit Function

Change_Err:
If Err = conPropNotFoundError Then " Property not found.
Set prp = dbs.CreateProperty(strPropName, _
varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
" Unknown error.
ChangeProperty = False
Resume Change_Bye
End If
End Function
" *********** Code End ***********
master8
  • 上一篇:破解Access(*.mdb)目前所有版本的密码
  • 下一篇:万维网创始人博客处女秀

  • 我要投稿  打印本文  推荐本文  加入收藏  返回顶部  关闭窗口
    搜模板(www.somoban.com) 原创网站模板交易平台
    阿里妈妈再掀疯狂采购风,网站广告位严重告急,急召天下站长
    基于PHP+MySQL的整站、模块、插件开发等或者按需求实现相应功能;
基于各PHP主流建站系统CMS,BBS,BLOG等的模板定制,完全手写代码;
整站数据迁移或备份恢复;网页代码优化、重构;整站常规SEO优化;网站技术支持;
点击了解详情...
    站长论坛
    • 验证码: