會(huì)員登錄 - 用戶注冊(cè) - 網(wǎng)站地圖 Office中國(guó)(office-cn.net),專業(yè)Office論壇
當(dāng)前位置:主頁 > 技巧 > Access技巧 > 數(shù)據(jù)庫系統(tǒng) > 正文

Access設(shè)置信任位置

時(shí)間:2013-07-31 22:09 來源:office中國(guó) 作者:andymark 閱讀:
在2007 和 2010 版本中打開數(shù)據(jù)庫文件,系統(tǒng)都會(huì)彈出安全警告提示框,對(duì)于用戶能確定安全的文件,可以新建一個(gè)文件夾集中存放在那里。然后設(shè)為信任位置,這樣打開該文件夾的數(shù)據(jù)庫就不會(huì)出現(xiàn)煩人的提示框了。
    我們可以按下面的步驟手動(dòng)添加 :【文件】>>【選項(xiàng)】>>【信任中心】>>【信任中心設(shè)置】 然后選擇右邊的【受信任位置】
    我們也可以用代碼實(shí)現(xiàn)上面的功能,使自已的程序更加趣味化
 
Dim strRegKEY As String
Dim APP_KEY As String
Dim Reg As New clsRegistry
Dim FrmState As Integer           '(1--增加,2--修改)
Dim FrmLocation As Integer        '傳遞參數(shù)
 
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 "請(qǐng)選擇受信任文件夾"
      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
 

(責(zé)任編輯:admin)

頂一下
(1)
100%
踩一下
(0)
0%
發(fā)表評(píng)論
請(qǐng)自覺遵守互聯(lián)網(wǎng)相關(guān)的政策法規(guī),嚴(yán)禁發(fā)布色情、暴力、反動(dòng)的言論。
評(píng)價(jià):