萬盛學電腦網

 萬盛學電腦網 >> 數據庫 >> access教程 >> access基礎教程 >> 創建一個帶密碼的空數據庫

創建一個帶密碼的空數據庫

Function CreatePasswordDB(strPathName As String, strPsd As String) As Boolean
On Error GoTo Exit_ERR
Dim wrkDefault As Workspace
Dim NewDB As Database

CreatePassWordDB = False
Set wrkDefault = DBEngine.Workspaces(0)
If Dir(strPathName) <> "" Then Kill strPathName
Set NewDB = wrkDefault.CreateDatabase(strPathName, dbLangGeneral & ";pwd=" & strPsd & "")

NewDB.Close
Set NewDB = Nothing

CreatePassWordDB = True
Exit Function

Exit_ERR:
MsgBox "備份失敗!" & VBCrLf & vbCrLf & Err.Description, vbExclamation
Exit Function
End Function

copyright © 萬盛學電腦網 all rights reserved