設為首頁收藏本站Access中國

Office中國論壇/Access中國論壇

 找回密碼
 注冊

QQ登錄

只需一步,快速開始

返回列表 發(fā)新帖
查看: 4539|回復: 4
打印 上一主題 下一主題

[模塊/函數] 有關ADP禁止SHIFT鍵的方法

[復制鏈接]

點擊這里給我發(fā)消息

跳轉到指定樓層
1#
發(fā)表于 2003-3-29 17:06:00 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
Function DisableBypassADP(blnYesNo As Boolean)
    CurrentProject.Properties.Add "AllowByPassKey", blnYesNo
End Function

然后在啟動時調用 DisableBypassADP(false)

更詳細的做法:

Function SetMyProperty(MyPropName As String, MyPropValue As Variant) As Boolean
    On Error GoTo SetMyProperty_In_Err
    Dim Ix As Integer
    With CurrentProject.Properties
    If fn_PropertyExist(MyPropName) Then  'check if it already exists
        For Ix = 0 To .Count - 1
            If .Item(Ix).Name = MyPropName Then
                .Item(Ix).Value = MyPropValue
            End If
        Next Ix
    Else
       .Add MyPropName, MyPropValue
    End If
    End With
    SetMyProperty = True

SetMyProperty_Exit:
    Exit Function

SetMyProperty_In_Err:
   
    MsgBox "設置屬性出錯:", Err, Error$
    SetMyProperty = False
    Resume SetMyProperty_Exit

End Function
'--------檢查屬性是否存在---
Private Function fn_PropertyExist(MyPropName As String) As Boolean
    fn_PropertyExist = False
    Dim Ix As Integer
    With CurrentProject.Properties
        For Ix = 0 To .Count - 1
            If .Item(Ix).Name = MyPropName Then
                fn_PropertyExist = True
                Exit For
            End If
        Next Ix
    End With
End Function


Public Function setByPass()
   SetMyProperty "AllowBypassKey", True
End Function


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏1 分享分享 分享淘帖 訂閱訂閱
2#
發(fā)表于 2003-3-29 21:30:00 | 只看該作者
好,收到。
3#
發(fā)表于 2003-3-30 00:16:00 | 只看該作者
AllowBypassKey 屬性
請參閱 示例 特性使用 AllowBypassKey 屬性可以指定是否允許用 Shift 鍵來忽略啟動屬性和 AutoExec 宏。例如,將 AllowBypassKey 屬性設為 False 可避免用戶忽略啟動屬性和 AutoExec 宏。

設置
AllowBypassKey 屬性使用以下設置:

設置 說明
True 允許用戶使用 Shift 忽略啟動屬性和 AutoExec 宏。
False 禁止用戶使用 Shift 忽略啟動屬性和 AutoExec 宏。


可以使用宏或者 Visual Basic 設置該屬性。

若要使用宏或 Visual Basic 設置 AllowBypassKey 屬性,必須使用以下方法創(chuàng)建該屬性:

在 Microsoft Access 數據庫 (.mdb) 中,可以通過使用 CreateProperty 方法添加該屬性,并將其追加到 Database 對象的 Properties 集合中。
注意這里:
在 Microsoft Access 項目 (.adp) 中,可以通過使用 Add 方法將該屬性添加到 CurrentProject 對象的 AccessObjectProperties 集合中。

說明
調試應用程序時,應確保 AllowBypassKey 屬性設為 True。

該屬性的設置僅在下一次打開應用程序數據庫時才會生效。

示例
下面的示例顯示了一個名為 SetBypassProperty 的過程,該過程傳遞要設置的屬性的名稱、數據類型及所需設置。一般用途過程 ChangeProperty 將嘗試設置 AllowBypassKey 屬性,如果找不到該屬性,則用 CreateProperty 方法將其追加到 Properties 集合中。這是必要的步驟,因為只有在添加之后,該屬性才出現(xiàn)在 Properties 集合中。

Sub SetBypassProperty()
Const DB_Boolean As Long = 1
    ChangeProperty "AllowBypassKey", DB_Boolean, False
    '--------------如果需要解開shift鎖定可以用以下代碼:
    'ChangeProperty "AllowBypassKey", DB_Boolean, true

End Sub

Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
    Dim dbs As Object, prp As Variant
    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

4#
發(fā)表于 2005-2-18 00:03:00 | 只看該作者
OK
5#
發(fā)表于 2021-10-15 19:04:57 | 只看該作者
很好
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則

QQ|站長郵箱|小黑屋|手機版|Office中國/Access中國 ( 粵ICP備10043721號-1 )  

GMT+8, 2024-10-23 06:24 , Processed in 0.095633 second(s), 28 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回復 返回頂部 返回列表