doandinhtam > 01-09-18, 02:46 PM
Private Sub Command14_Click()
Dim dlgSaveAs As FileDialog
Dim strFilePath As String
Dim strFileName As String
Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)
dlgSaveAs.Show
strFilePath = dlgSaveAs.SelectedItems(1)
Me.txtsave = strFilePath
strFileName = Right(strFilePath, Len(strFilePath) - InStrRev(strFilePath, "\"))
strFilePath = Left(strFilePath, InStrRev(strFilePath, "\"))
Dim sFile As String, oDB As DAO.Database
sFile = txtsave & ".bak"
If Dir(sFile) <> "" Then Kill sFile
Set oDB = DBEngine.Workspaces(0).CreateDatabase(sFile, dbLangGeneral)
oDB.Close
DoCmd.Hourglass True
Dim oTD As TableDef
For Each oTD In CurrentDb.TableDefs
If Left(oTD.Name, 4) <> "MSys" Then
DoCmd.CopyObject sFile, , acTable, oTD.Name
End If
Next oTD
DoCmd.Hourglass False
MsgBox "Sao luu du lieu xong"
End Sub
ongke0711 > 02-09-18, 12:37 AM
Dim dlgSaveAs As FileDialog
Dim strFilePath As String
Dim strFileName As String
Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)
dlgSaveAs.Show
With dlgSaveAs
If .SelectedItems.Count = 0 Then
MsgBox "Khong chon file nao."
Exit Sub
Else
strFilePath = dlgSaveAs.SelectedItems(1)
Me.txtsave = strFilePath
End If
End With
strFileName = Right(strFilePath, Len(strFilePath) - InStrRev(strFilePath, "\"))
strFilePath = Left(strFilePath, InStrRev(strFilePath, "\"))
Dim sFile As String, oDB As DAO.Database
sFile = txtsave & ".bak"
If Dir(sFile) <> "" Then Kill sFile
Set oDB = DBEngine.Workspaces(0).CreateDatabase(sFile, dbLangGeneral)
oDB.Close
DoCmd.Hourglass True
Dim oTD As TableDef
For Each oTD In CurrentDb.TableDefs
If Left(oTD.Name, 4) <> "MSys" Then
DoCmd.CopyObject sFile, , acTable, oTD.Name
End If
Next oTD
DoCmd.Hourglass False
MsgBox "Sao luu du lieu xong"
doandinhtam > 02-09-18, 09:48 AM