閉じる

DBをバックアップする。(コピー、最適化) DBEngine.CompactDatabase


Private Sub cmdBackUp_Click()

'----------------------------------------------------------------

' コピー、最適化を使ってMDBをバックアップします。

' バックアップ元のDBは閉じている必要があります。

'---------------------------------------------------------------

On Error GoTo Err_cmdBackUp

        

        If IsNull(Me.backupMOTO) = True Then

           MsgBox "バックアップ元パス名が未入力です。"

           GoTo Exit_cmdBackUp

        End If

     

        If Len(Me.backupMOTO) = 0 Then

           MsgBox "バックアップ元パス名が未入力です。"

           GoTo Exit_cmdBackUp

        End If



        

        If IsNull(Me.backupSAKI) = True Then

           MsgBox "バックアップ先パス名が未入力です。"

           GoTo Exit_cmdBackUp

        End If

     

        If Len(Me.backupSAKI) = 0 Then

           MsgBox "バックアップ先パス名が未入力です。"

           GoTo Exit_cmdBackUp

        End If



        Dim ret As Integer

    

        ret = MsgBox(Me.backupMOTO & " から、" & Me.backupSAKI & "にバックアップを行います。" & Chr(13) & _

                        "よろしいですか?", vbYesNo + vbQuestion, "削除")

        If ret = vbNo Then

            '削除中止

            GoTo Exit_cmdBackUp

        End If



        'バックアップ(コピー、最適化)

        DBEngine.CompactDatabase Me.backupMOTO, backupSAKI, , , ";pwd=xxxxxxx"





        MsgBox "処理完了"



Exit_cmdBackUp:

Exit Sub



Err_cmdBackUp:

    MsgBox ("cmdBackUp:" & Err.Number & " " & Err.Description)

    Resume Exit_cmdBackUp



End Sub