璁剧疆鍙湁绠$悊鍛樻墠鑳芥敼鍙楢llowBypassKey灞炴
鍙戝竷: 2008-7-01 15:17 | 浣滆: admin | 鏌ョ湅: 6娆

璁剧疆鍙湁绠$悊鍛樻墠鑳芥敼鍙楢llowBypassKey灞炴
鐑
銆愬瓧浣擄細灏 澶с
璁剧疆鍙湁绠$悊鍛樻墠鑳芥敼鍙楢llowBypassKey灞炴
浣滆咃細- 鏂囩珷鏉ユ簮锛- 鐐瑰嚮鏁帮細710 鏇存柊鏃堕棿锛2006-12-13 
tmtony缈昏瘧锛
鍦ˋCCESS鐨勫府鍔╂枃浠朵腑璇存槑CreateProperty 鏂规硶鐨勮娉曪細
Set property = object.CreateProperty (name, type, value, DDL)
鍏跺疄鏈鍚庝竴涓弬鏁版槸杩欎釜瑙i噴鐨勶紙閮ㄥ垎鎻忚堪锛夛細
DDL 鍙. 涓涓彉閲(閫昏緫瀛愮被鍨) 鎸囧畾杩欎釜灞炴ф槸鍚︿负DDL瀵硅薄. 缂哄皯鍊间负False. 濡傛灉璁剧疆涓篢RUE锛岄櫎闈炰粬鏈 dbSecWriteDef 鏉冮檺锛岀敤鎴峰氨涓嶈兘鏀瑰彉鎴栧垹闄よ繖涓睘鎬
CreateProperty 鏄敤鏉ュ垱寤烘垨璁剧疆 AllowBypassKey 灞炴у鏋滆繖涓睘鎬ц涓篢RUE, 閭e氨鍙互绂佺敤鎴疯繎SHIFT閿潵绂佹鍚姩灞炴у拰AutoExec 瀹. 鐒惰岋紝ACCESS甯姪涓彁渚涚殑渚嬪瓙娌℃湁浣跨敤绗洓涓 DDL 鍙傛暟. 杩欐剰鍛崇潃浠讳綍浜洪兘鍙互鎵撳紑鏁版嵁鎹劧鍚庣敤绋嬪簭澶嶄綅AllowBypassKey 灞炴.
鎵浠ワ紝涓轰簡闄愬埗鏅氱敤鎴峰幓鏀瑰彉杩欎釜灞炴э紝鎵浠ユ垜浠缃鍥涗釜鍙傛暟涓篢RUE 銆
涓轰簡瀵规瘮锛屾垜浠篃鍚屾椂鍒楀嚭浜咥CCESS鏈韩鐨勪緥瀛愪互渚垮弬鐓
' *********** 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 ***********




发表于 2009-1-5 19:48
| 











