

启动/设置/选项/背景
Access设置信任位置
2013-07-31 20:28:05
在2007 和 2010 版本中打开数据库文件,系统都会弹出安全警告提示框,对于用户能确定安全的文件,可以新建一个文件夹集中存放在那里。然后设为信任位置,这样打开该文件夹的数据库就不会出现烦人的提示框了。 我们可以按下面的步骤手动添加 :【文件】>>【选项】>>【信任中心】>>【信任中心设置】 然后选择右边的【受信任位置】 我们也可以用代码来实现上面的功能,使自已的程序更加趣味化
Dim strRegKEY As String
Dim APP_KEY As String
Dim Reg As New clsRegistry
Dim FrmState As Integer '(1--增加,2--修改)
Dim FrmLocation As Integer '传递参数
Private Sub Form_Load()
APP_KEY = "Software\Microsoft\Office\" & Format(Application.Version, "##,##0.0") & _
"\Access\Security\Trusted Locations\Location"
strRegKEY = "HKEY_CURRENT_USER\" & APP_KEY
FrmState = SysState
FrmLocation = SysLocation
If FrmState = 2 Then
Call ShowBill(FrmLocation)
Else
Call AddBill
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
SysState = 0
SysLocation = 0
Set Reg = Nothing
End Sub
Private Sub CmdOK_Click() '确定
Dim IntAllow As Integer
Dim strPath As String
If Len(Me.TxtFolderPath) = 0 Then
Me.TxtFolderPath.SetFocus
MsgBox "请选择受信任文件夹"
Exit Sub
End If
If Len(Me.TxtDescription) = 0 Then
Me.TxtDescription.SetFocus
MsgBox "说明不能为空"
Exit Sub
End If
If Right(Me.TxtFolderPath, 1) <> "\" Then
strPath = Me.TxtFolderPath & "\"
Else
strPath = Me.TxtFolderPath
End If
If Me.ChkAllow = True Then
IntAllow = 1
Else
IntAllow = 0
End If
If FrmState <> 2 Then
FrmLocation = GetUnUsedLocation
End If
Call SetTrustedLocation(FrmLocation, strPath, Trim(Me.TxtDescription), CStr(Now), IntAllow)
If FrmState = 2 Or FrmState = 1 Then
Call Forms("受信任位置").ShowBill
DoCmd.Close acForm, Me.Name
End If
End Sub