Notifications
Clear all

compactar BD no vba - access

6 Posts
2 Usuários
0 Reactions
1,670 Visualizações
(@joanas)
Posts: 48
Eminent Member
Topic starter
 

bom dia,

como é que posso compactar a minha bd em access através do vba?

obrigada

 
Postado : 19/02/2015 6:23 am
Fernando Fernandes
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Bom dia!!

Talvez....

Function CreateNewDatabase(FileName As String) As Boolean
'Fonte:http://www.experts-exchange.com/Database/MS_Access/Q_27937899.html
Dim ws As Workspace
Dim db As Database

Set ws = DBEngine.Workspaces(0)
'/ Delete any existing files:
    If Dir(FileName) <> "" Then
      Kill FileName
    End If
' Create the new database
Set db = ws.CreateDatabase(FileName, dbLangGeneral)
'/ Now export your tables. Note that I've set StructureOnly=True
DoCmd.TransferDatabase TransferType:=acExport, DatabaseName:=FileName, ObjectType:=acTable, Source:="YourLocalTable", Destination:="YourRemoteTable", StructureOnly:=True
'/ add other TransferDatabase calls here to move desired tables to the new database
End Function

Att

Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel

 
Postado : 19/02/2015 6:40 am
(@joanas)
Posts: 48
Eminent Member
Topic starter
 

DoCmd.TransferDatabase TransferType:=acExport, DatabaseName:=FileName, ObjectType:=acTable, Source:="YourLocalTable", Destination:="YourRemoteTable", StructureOnly:=True

aparece-me um erro nesta linha, run-time error 2507: the type isn't an installed database type or doesn't support the operation you chose.

 
Postado : 19/02/2015 6:53 am
Fernando Fernandes
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Bom dia!!

Cara, tu vai ter adaptar o código (apontar o caminho correto)

Destination:="YourRemoteTable", 

, sua tabela está neste local? :? :?

Att

Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel

 
Postado : 19/02/2015 6:59 am
(@joanas)
Posts: 48
Eminent Member
Topic starter
 

sim eu sei, eu mudei e deu esse erro :

 
Postado : 19/02/2015 7:19 am
Fernando Fernandes
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Bom dia!!

Olha eu não consigo testar, pois no pacote office do meu trabalho não tem Access, vamos aguardar o pessoal lhe ajudar.

Att

Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel

 
Postado : 19/02/2015 7:28 am