Private Sub Command43_Click()
Call CreateDummyfile
StartPasswordedDatabaseRuntime "D:\sa.accdr", 123
End Sub
Sub StartPasswordedDatabaseRuntime( _
strPathToDatabase As String, _
Optional strPassword As String, _
Optional strPathToRuntime As String, _
Optional blnQuit As Boolean)
' Start a runtime database that has a database password.
Dim appRT As Access.Application
Dim strPathToDummy As String
Dim blnStillOpen As Boolean
Const Q As String = """"
If Len(strPassword) = 0 Then
strPassword = InputBox("Please enter password:")
End If
If Len(strPathToRuntime) = 0 Then
strPathToRuntime = SysCmd(acSysCmdAccessDir) & "msaccess.exe"
End If
strPathToDummy = CurrentProject.path & "\Dummy.accdb"
Shell _
Q & strPathToRuntime & Q & " " & Q & strPathToDummy & Q & " /runtime", vbMinimizedFocus
Set appRT = GetObject(strPathToDummy)
With appRT
.CloseCurrentDatabase
.OpenCurrentDatabase strPathToDatabase, , strPassword
End With
On Error Resume Next
blnStillOpen = True
Do While blnStillOpen
DoEvents
Err.Clear
If appRT Is Nothing Then
blnStillOpen = False
ElseIf Len(appRT.CurrentProject.Path) = 0 Then
blnStillOpen = False
End If
If Err.Number <> 0 Then
blnStillOpen = False
End If
Loop
If blnQuit Then
Application.Quit ' if we're done here.
End If
End Sub
Private Sub CreateDummyfile()
Dim obj As Object
Set obj = CreateObject("access.application")
If Dir("D:\Dummy.accdb") = "" Then
obj.NewCurrentDatabase ("D:\Dummy.accdb")
End If
End Sub
برای ثبت پاسخ لازم است وارد شوید. از فرم مقابل برای ورود استفاده منید و اگر کاربر جدید هستید ثبت نام کنید.
اینجا ثبت نام کنید »