Copy tables from original DB to another (1 Viewer)

tihmir

Registered User.
Local time
Yesterday, 21:07
Joined
May 1, 2018
Messages
216
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?
 

Isaac

Lifelong Learner
Local time
Yesterday, 21:07
Joined
Mar 14, 2017
Messages
6,454
Because you have slashes in the filename

Right-click on your desktop and try actually making a file named 04/20/2021.txt
 

tihmir

Registered User.
Local time
Yesterday, 21:07
Joined
May 1, 2018
Messages
216
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?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 21:07
Joined
Oct 29, 2018
Messages
18,962
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"
 

tihmir

Registered User.
Local time
Yesterday, 21:07
Joined
May 1, 2018
Messages
216
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:

Minty

AWF VIP
Local time
Today, 05:07
Joined
Jul 26, 2013
Messages
9,286
This
"\\192.168.200.222\dzk\DZK\InfSisDZK1_Mo_T01.accdb\01 Objet"
cannot be the correct path to the database file?
 

tihmir

Registered User.
Local time
Yesterday, 21:07
Joined
May 1, 2018
Messages
216
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:

Minty

AWF VIP
Local time
Today, 05:07
Joined
Jul 26, 2013
Messages
9,286
\\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.
 

tihmir

Registered User.
Local time
Yesterday, 21:07
Joined
May 1, 2018
Messages
216
\\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
 

Minty

AWF VIP
Local time
Today, 05:07
Joined
Jul 26, 2013
Messages
9,286
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
 

tihmir

Registered User.
Local time
Yesterday, 21:07
Joined
May 1, 2018
Messages
216
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

Top Bottom