設(shè)為首頁收藏本站Access中國

Office中國論壇/Access中國論壇

 找回密碼
 注冊

QQ登錄

只需一步,快速開始

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

[模塊/函數(shù)] 有關(guān)ADP禁止SHIFT鍵的方法

[復(fù)制鏈接]

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

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

然后在啟動(dòng)時(shí)調(diào)用 DisableBypassADP(false)

更詳細(xì)的做法:

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 "設(shè)置屬性出錯(cuò):", 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 鍵來忽略啟動(dòng)屬性和 AutoExec 宏。例如,將 AllowBypassKey 屬性設(shè)為 False 可避免用戶忽略啟動(dòng)屬性和 AutoExec 宏。

設(shè)置
AllowBypassKey 屬性使用以下設(shè)置:

設(shè)置 說明
True 允許用戶使用 Shift 忽略啟動(dòng)屬性和 AutoExec 宏。
False 禁止用戶使用 Shift 忽略啟動(dòng)屬性和 AutoExec 宏。


可以使用宏或者 Visual Basic 設(shè)置該屬性。

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

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

說明
調(diào)試應(yīng)用程序時(shí),應(yīng)確保 AllowBypassKey 屬性設(shè)為 True。

該屬性的設(shè)置僅在下一次打開應(yīng)用程序數(shù)據(jù)庫時(shí)才會(huì)生效。

示例
下面的示例顯示了一個(gè)名為 SetBypassProperty 的過程,該過程傳遞要設(shè)置的屬性的名稱、數(shù)據(jù)類型及所需設(shè)置。一般用途過程 ChangeProperty 將嘗試設(shè)置 AllowBypassKey 屬性,如果找不到該屬性,則用 CreateProperty 方法將其追加到 Properties 集合中。這是必要的步驟,因?yàn)橹挥性谔砑又,該屬性才出現(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 | 只看該作者
很好
回復(fù)

使用道具 舉報(bào)

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

本版積分規(guī)則

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

GMT+8, 2025-7-13 08:07 , Processed in 0.082214 second(s), 28 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回復(fù) 返回頂部 返回列表