在Access中禁用旁路键

时间:2015-10-08 16:46:12

标签: access-vba shift

我正在尝试禁用shift键选项以取消隐藏数据库中的所有对象。我尝试了许多不同的代码变体,但似乎都没有。这可能是因为我在.ACCDB数据库中工作或者我的代码有问题吗?我已经提供了以下代码。

谢谢!

Public Function SetProperties(strPropName As String, _
varPropType As Variant, varPropValue As Variant) As Integer

On Error GoTo Err_SetProperties

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

Set db = CurrentDb
db.Properties(strPropName) = varPropValue
SetProperties = True
Set db = Nothing

Exit_SetProperties:
Exit Function

Err_SetProperties:
If Err = 3270 Then    'Property not found
    Set prp = db.CreateProperty(strPropName, varPropType, varPropValue)
    db.Properties.Append prp
    Resume Next
Else
    SetProperties = False
    MsgBox "SetProperties", Err.Number, Err.Description
    Resume Exit_SetProperties
End If

1 个答案:

答案 0 :(得分:1)

@Service
@Path("/new/foo")
public class FooV2Class implements moduleInterface {
public Response getSomething(@Valid Request obj){
// code
}
}

了解更多信息;我使用一个驱动各种设置的数据表,移位旁路和你可能感兴趣的其他设备一样。


Public Function F_AutoExec_Setup()
    Dim DB_prop As Property
    Dim PropName As String
    Dim PropValue As Boolean
    Dim TempC As Integer
    Dim bars As String


    DoCmd.Hourglass True

    On Error GoTo AddProps_Err
    'Change Setting for Special Keys - F11, etc
    PropName = "AllowSpecialKeys"
    PropValue = Nz(DLookup("[Status]", "tbl_DB_Settings", "[Code] = 1"), True)
    CurrentDb.Properties(PropName) = PropValue

    'Change Setting for The shift bypass key
    PropName = "AllowBypassKey"
    PropValue = Nz(DLookup("[Status]", "tbl_DB_Settings", "[Code] = 2"), True)
    CurrentDb.Properties(PropName) = PropValue

    'Change Setting for Full Menus
    PropName = "AllowFullMenus"
    PropValue = Nz(DLookup("[Status]", "tbl_DB_Settings", "[Code] = 3"), True)
    CurrentDb.Properties(PropName) = PropValue

    'Change Setting for Built-in Toolbars
    PropName = "AllowBuiltInToolbars"
    PropValue = Nz(DLookup("[Status]", "tbl_DB_Settings", "[Code] = 4"), True)
    CurrentDb.Properties(PropName) = PropValue

    'Change Setting for Toolbar Changes
    PropName = "AllowToolbarChanges"
    PropValue = Nz(DLookup("[Status]", "tbl_DB_Settings", "[Code] = 5"), True)
    CurrentDb.Properties(PropName) = PropValue

    'Change Setting for errors allowing Code Debug
    PropName = "AllowBreakIntoCode"
    PropValue = Nz(DLookup("[Status]", "tbl_DB_Settings", "[Code] = 6"), True)
    CurrentDb.Properties(PropName) = PropValue

    'Change Setting for display of the navigation pane
    PropName = "StartupShowDBWindow"
    PropValue = Nz(DLookup("[Status]", "tbl_DB_Settings", "[Code] = 7"), True)
    CurrentDb.Properties(PropName) = PropValue

    'Change Setting for Shortcut menus
    PropName = "AllowShortcutMenus"
    PropValue = Nz(DLookup("[Status]", "tbl_DB_Settings", "[Code] = 8"), True)
    CurrentDb.Properties(PropName) = PropValue

    'Disable all the normal Toolbars
    PropValue = Nz(DLookup("[Status]", "tbl_DB_Settings", "[Code] = 12"), True)
    If PropValue Then
        PropValue = False
    Else
        PropValue = True
    End If
    On Error Resume Next 'Some of the toolbars do not have a visible option, this traps that
    For TempC = 1 To CommandBars.Count
        CommandBars(TempC).Enabled = PropValue
        'Only check/change visible status if we are turning things off, otherwise we make a mess
        'of the screen with all the toolbars at once.
        If Not PropValue And CommandBars(TempC).Visible  PropValue Then
            CommandBars(TempC).Visible = PropValue
        End If
        If Error Then
            Err.Clear
        End If
    Next TempC

    'Change Setting for display of the QAT and the Ribbon
    PropValue = Nz(DLookup("[Status]", "tbl_DB_Settings", "[Code] = 9"), True)
    If PropValue Then
        DoCmd.ShowToolbar "Ribbon", acToolbarYes

    Else
        DoCmd.ShowToolbar "Ribbon", acToolbarNo
    End If

    'Change Setting for display of Form View Toolbar
    PropValue = Nz(DLookup("[Status]", "tbl_DB_Settings", "[Code] = 10"), False)
    If PropValue Then
        DoCmd.ShowToolbar "Form View", acToolbarYes
    Else
        DoCmd.ShowToolbar "Form View", acToolbarNo
    End If

    'Change Setting for display of Print PreView Toolbar
    PropValue = Nz(DLookup("[Status]", "tbl_DB_Settings", "[Code] = 11"), False)
    If PropValue Then
        DoCmd.ShowToolbar "Print Preview", acToolbarYes
    Else
        DoCmd.ShowToolbar "Print Preview", acToolbarNo
    End If

    'Change Setting for display of Table Design Toolbar
    PropValue = Nz(DLookup("[Status]", "tbl_DB_Settings", "[Code] = 13"), False)
    If PropValue Then
        DoCmd.ShowToolbar "Table Design", acToolbarYes
    Else
        DoCmd.ShowToolbar "Table Design", acToolbarNo
    End If

    'Change Setting for display of Query Design Toolbar
    PropValue = Nz(DLookup("[Status]", "tbl_DB_Settings", "[Code] = 14"), False)
    If PropValue Then
        DoCmd.ShowToolbar "Query Design", acToolbarYes
    Else
        DoCmd.ShowToolbar "Query Design", acToolbarNo
    End If

    'Change Setting for display of Query Datasheet Toolbar
    PropValue = Nz(DLookup("[Status]", "tbl_DB_Settings", "[Code] = 15"), False)
    If PropValue Then
        DoCmd.ShowToolbar "Query Datasheet", acToolbarYes
    Else
        DoCmd.ShowToolbar "Query Datasheet", acToolbarNo
    End If

    'Change Setting for display of Table Datasheet Toolbar
    PropValue = Nz(DLookup("[Status]", "tbl_DB_Settings", "[Code] = 16"), False)
    If PropValue Then
        DoCmd.ShowToolbar "Table Datasheet", acToolbarYes
    Else
        DoCmd.ShowToolbar "Table Datasheet", acToolbarNo
    End If

   'Change Setting for display of Form Design Toolbar
    PropValue = Nz(DLookup("[Status]", "tbl_DB_Settings", "[Code] = 17"), False)
    If PropValue Then
        DoCmd.ShowToolbar "Form Design", acToolbarYes
    Else
        DoCmd.ShowToolbar "Form Design", acToolbarNo
    End If

    'Change Setting for display of Report Design Toolbar
    PropValue = Nz(DLookup("[Status]", "tbl_DB_Settings", "[Code] = 18"), False)
    If PropValue Then
        DoCmd.ShowToolbar "Report Design", acToolbarYes
    Else
        DoCmd.ShowToolbar "Report Design", acToolbarNo
    End If

    'Change Setting for display of Macro Design Toolbar
    PropValue = Nz(DLookup("[Status]", "tbl_DB_Settings", "[Code] = 19"), False)
    If PropValue Then
        DoCmd.ShowToolbar "Macro Design", acToolbarYes
    Else
        DoCmd.ShowToolbar "Macro Design", acToolbarNo
    End If

    'Change Setting for locking of the Navigation Pane
    PropValue = Nz(DLookup("[Status]", "tbl_DB_Settings", "[Code] = 20"), True)
    If PropValue Then
        DoCmd.LockNavigationPane False
    Else
        DoCmd.LockNavigationPane True
    End If



    GoTo Props_End

AddProps_Err:

    If Nz(Err.Number, 0) = 3270 Then
        ' Property not found when adding a property value.
        Set DB_prop = CurrentDb.CreateProperty(PropName, dbBoolean, PropValue, False)
        CurrentDb.Properties.Append DB_prop
        Set DB_prop = Nothing
        Resume Next
    Else
        MsgBox Err.Number & " - " & Err.Description
        Resume Props_End
    End If


Props_End:
    DoCmd.Hourglass False
End Function