设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 976|回复: 0
打印 上一主题 下一主题

[其它] 请问怎样用ADD的方法添加属性?

[复制链接]
跳转到指定楼层
1#
发表于 2004-9-19 05:28:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
使用 AllowBypassKey 属性可以指定是否允许用 Shift 键来忽略启动属性和 AutoExec 宏。


  • 在 [url=mkMSITStore:E:\Program%20Files\Microsoft%20Office\OFFICE11\2052\vbaac10.chm::/html/acproAllowBypassKey.htm#]Microsoft Access 数据库[/url] (.mdb) 中,可以通过使用 CreateProperty 方法添加该属性,并将其追加到 Database 对象的 Properties 集合中。






  • 在 [url=mkMSITStore:E:\Program%20Files\Microsoft%20Office\OFFICE11\2052\vbaac10.chm::/html/acproAllowBypassKey.htm#]Microsoft Access 项目[/url] (.adp) 中,可以通过使用 [url=mkMSITStore:E:\Program%20Files\Microsoft%20Office\OFFICE11\2052\vbaac10.chm::/html/acmthAdd.htm]Add[/url] 方法将该属性添加到 CurrentProject 对象的 AccessObjectProperties 集合中。


下面的示例显示了一个名为 SetBypassProperty 的过程,该过程传递要设置的属性的名称、数据类型及所需设置。一般用途过程 ChangeProperty 将尝试设置 AllowBypassKey 属性,如果找不到该属性,则用 CreateProperty 方法将其追加到 Properties 集合中。这是必要的步骤,因为只有在添加之后,该属性才出现在 Properties 集合中。
  1. Sub SetBypassProperty()

  2. Const DB_Boolean As Long = 1

  3.     ChangeProperty "[b]AllowBypassKey[/b]", DB_Boolean, False

  4. End Sub



  5. Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer

  6.     Dim dbs As Object, prp As Variant

  7.     Const conPropNotFoundError = 3270



  8.     Set dbs = CurrentDb

  9.     On Error GoTo Change_Err

  10.     dbs.Properties(strPropName) = varPropValue

  11.     ChangeProperty = True



  12. Change_Bye:

  13.     Exit Function



  14. Change_Err:

  15.     If Err = conPropNotFoundError Then    ' Property not found.

  16.         Set prp = dbs.CreateProperty(strPropName,varPropType, varPropValue)

  17.         dbs.Properties.Append prp

  18.         Resume Next

  19.     Else

  20.         ' Unknown error.

  21.         ChangeProperty = False

  22.         Resume Change_Bye

  23.     End If

  24. End Function
复制代码
[code][/code]

  请问怎样用ADD的方法添加属性?上面的代码应该怎样改?

[此贴子已经被作者于2004-9-18 21:34:23编辑过]

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-5 14:27 , Processed in 0.149247 second(s), 24 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表