lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long Dim FFILE As String Dim mPath As String Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long Private Const FO_COPY = &H2 Private Const FOF_ALLOWUNDO = &H40
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset Dim intcount As Integer
Private Type SHFILEOPSTRUCT
hwnd As Long wfunc As Long pfrom As String pto As String fFlags As Integer Faborted As Boolean hnamemaps As Long sprogress As String End Type
Private Sub Form_Load()
con.Provider = "Microsoft.Jet.OLEDB.4.0" con.CursorLocation = adUseClient con.Open (App.Path + "\DbSekolah.mdb") End Sub
CommonDialog1.DialogTitle = "Restore Databse" CommonDialog1.Filter = "(*.mdb)|*.mdb" CommonDialog1.ShowOpen mPath = CommonDialog1.FileName If mPath <> "" Then copyfile mPath, App.Path & "\DbSekolah.mdb", 0 MsgBox "Restore Database Berhasil", vbInformation, "Info" Exit Sub End If End Sub
Private Sub CmdTbSiswa_Click()
On Error GoTo pesan: Dim z As String z = InputBox("Masukan nama backup tabel:", "Backup File", "Backup TbSiswa ") If z = "" Then Exit Sub If z <> "TbSiswa" Then con.Execute "select * into [Excel 8.0;" & _ "Database=" & App.Path & "\Backup\" + z + ".xls].[TbSiswa]" & _ "from TbSiswa", intcount MsgBox (CStr(intcount) + " " & "Record berhasil diexport") Exit Sub pesan: MsgBox "Nama Backup Tabel sudah ada", , "Info" Exit Sub End If End Sub
Private Sub CmdTbPembayaran_Click()
On Error GoTo pesan: Dim z As String z = InputBox("Masukan nama backup tabel:", "Backup File", "Backup TbPembayaran ") If z = "" Then Exit Sub If z <> "TbPembayaran" Then con.Execute "select * into [Excel 8.0;" & _ "Database=" & App.Path & "\Backup\" + z + ".xls].[TbPembayaran]" & _ "from TbPembayaran", intcount MsgBox (CStr(intcount) + " " & "Record berhasil diexport") Exit Sub pesan: MsgBox "Nama Backup Tabel sudah ada", , "Info" Exit Sub End If End Sub
Public Sub copy(ByVal asal As String, ByVal tujuan As String)
Dim X As SHFILEOPSTRUCT With X .hwnd = 0 .wfunc = FO_COPY .pfrom = asal & vbNullChar & vbNullChar .pto = tujuan & vbNullChar & vbNullChar .fFlags = FOF_ALLOWUNDO End With SHFileOperation X End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path End Sub
Private Sub Dir2_Change()
TxtTujuan.Text = Dir2.Path End Sub
Private Sub Drive1_Change()
On Error Resume Next Dir1.Path = Drive1.Drive End Sub
Private Sub Drive2_Change()
On Error Resume Next Dir2.Path = Drive2.Drive End Sub
Private Sub File1_Click()
TxtSumber.Text = File1.Path & "\" & File1.FileName End Sub Private Sub CmdCopy_Click() On Error Resume Next If TxtSumber = "" Then MsgBox "Anda belum memilih File Sumber", , "Pesan" Exit Sub ElseIf TxtTujuan = "" Then MsgBox "Anda belum memilih Directory Tujuan", , "Pesan" Exit Sub End If copy TxtSumber.Text, TxtTujuan.Text MsgBox "File sudah di copy", , "Info" Me.TxtSumber = "" Me.TxtTujuan = "" Exit Sub End Sub