|
窗体中设置如下
Private Sub Form_Open(Cancel As Integer)
Application.RunCommand acCmdAppMinimize
DoCmd.Restore
公用模块可以设置如下
Public Sub AdminStartupProperties() '启动管理员权限
Const DB_Text As Long = 10
Const DB_Boolean As Long = 1
ChangeProperty "StartupForm", DB_Text, "frmLoad"
ChangeProperty "StartupShowDBWindow", DB_Boolean, True
ChangeProperty "StartupShowStatusBar", DB_Boolean, True
ChangeProperty "AllowBuiltinToolbars", DB_Boolean, True
ChangeProperty "AllowFullMenus", DB_Boolean, True
ChangeProperty "AllowBreakIntoCode", DB_Boolean, True
ChangeProperty "AllowSpecialKeys", DB_Boolean, True
ChangeProperty "AllowBypassKey", DB_Boolean, True
ChangeProperty "AppTitle", DB_Text, gAppName
ChangeProperty "AppIcon", DB_Text, CurrentProject.Path & "\wh.ico"
MsgBox "管理员权限已开启,请重新启动程序!"
End Sub
Public Sub UserStartupProperties() '用户权限
Const DB_Text As Long = 10
Const DB_Boolean As Long = 1
If CurrentDb().Properties("StartupShowDBWindow") = True Then
ChangeProperty "StartupForm", DB_Text, "frmLoad"
ChangeProperty "StartupShowDBWindow", DB_Boolean, False
ChangeProperty "StartupShowStatusBar", DB_Boolean, False
ChangeProperty "AllowBuiltinToolbars", DB_Boolean, True
ChangeProperty "AllowFullMenus", DB_Boolean, False
ChangeProperty "AllowBreakIntoCode", DB_Boolean, False
ChangeProperty "AllowSpecialKeys", DB_Boolean, False
ChangeProperty "AllowBypassKey", DB_Boolean, False
ChangeProperty "AppTitle", DB_Text, gAppName
ChangeProperty "AppIcon", DB_Text, CurrentProject.Path & "\wh.ico"
End If
End Sub
Private 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
' 未知错误。
ChangeProperty = False
Resume Change_Bye
End If
End Function |
|