Copy tables from original DB to another

tihmir

Registered User.
Local time
, 19:36
Joined
May 1, 2018
Messages
257
Hi, I need to backup my database.
I'm trying to copy tables from original database that is on a server, by pressing a button,
to another database. I use this code, but it gives an error a error:
Code:
Private Sub b1_Click()
     Dim FileNameOrig As String
     Dim FileNameCopy As String
     Dim d, d1, d2, d3 As String
     d1 = Format(Date, "dd/mm/yyyy")
     d2 = Format(Time, "hh/mm")
     d = d1 & "_" & d2
     FileNameOrig = "D:\DZK_T01\System\BD.accdb"
     FileNameCopy = "D:\DZK_T01\ArchivBD\ArhivBD_InfSisDZK1 _" & d & ".accdb"
     FileCopy FileNameOrig, FileNameCopy
     DoCmd.CopyObject FileNameCopy, "\\192.168.200.222\dzk\DZK\InfSisDZK1_Mo_T01.accdb\01 Objet", acTable, "01 Objet"
End Sub
Is there another way to do back up on my database?
 
Because you have slashes in the filename

Right-click on your desktop and try actually making a file named 04/20/2021.txt
 
Because you have slashes in the filename

Right-click on your desktop and try actually making a file named 04/20/2021.txt
Yes, you're right. But how it should be written correctly?
 
Yes, you're right. But how it should be written correctly?
This is how I did it in the link I posted earlier.
Code:
    strDestination = CurrentProject.Path & strFileName & " (" _
            & Format(Now, "yyyymmddhhnnss") & ").accdb"
 
You can use the Format() function without the slashes.
I changed my format like this:
d1 = Format(Date, "ddmmyyyy")
d2 = Format(Time, "hhmm")
but now I have error '2006"
on this row :
DoCmd.CopyObject FileNameCopy, "\\192.168.200.222\dzk\DZK\InfSisDZK1_Mo_T01.accdb\01 Objet", acTable, "01 Objet"
 
Last edited:
This
"\\192.168.200.222\dzk\DZK\InfSisDZK1_Mo_T01.accdb\01 Objet"
cannot be the correct path to the database file?
 
This
"\\192.168.200.222\dzk\DZK\InfSisDZK1_Mo_T01.accdb\01 Objet"
cannot be the correct path to the database file?
The database is uploaded to a server with this address.: \\192.168.200.222\dzk\DZK\InfSisDZK1_Mo_T01.accdb
I'm trying to access but it gives me an error. How to find the correct path to the database on the server?
 
Last edited:
\\192.168.200.222\dzk\DZK\InfSisDZK1_Mo_T01.accdb

is not the same as

\\192.168.200.222\dzk\DZK\InfSisDZK1_Mo_T01.accdb\01 Objet

One has a spurious \o1 Objct after it.
 
\\192.168.200.222\dzk\DZK\InfSisDZK1_Mo_T01.accdb\01 Objet

One has a spurious \o1 Objct after it.
Sorry for my spelling mistake, but "01 Object" is the name of the table I'm trying to copy from the database to another database that
 
Okay if it's just one table then try this method

Code:
Dim sTargetDb as String

 sTargetDb = "\\192.168.200.222\dzk\DZK\InfSisDZK1_Mo_T01.accdb"

 DoCmd.TransferDatabase acExport, "Microsoft Access", sTargetDb , acTable, "01 Object", "01 Object", True
 
Okay if it's just one table then try this method

Code:
Dim sTargetDb as String

sTargetDb = "\\192.168.200.222\dzk\DZK\InfSisDZK1_Mo_T01.accdb"

DoCmd.TransferDatabase acExport, "Microsoft Access", sTargetDb , acTable, "01 Object", "01 Object", True
Тhank you, I will try your solution and return feedback. Thank you again!
 

Users who are viewing this thread

Back
Top Bottom