Issue copying MS database from active application

J

JHB

Hi:

I am trying to set up a process where a user can click a button and
backup the active database to another drive with a simple copy.

I have set the following code:

Function BUDB()


Dim OLDFILE As String
Dim BUFILE As String
Dim NOWSTRING As String
BUFOLDER = "C:/TASC/BACKUP/"
NOWSTRING = Format(Now(), "yyyy-mm-dd")
OLDFILE = "c:/TASC/DB/TASC_be.mdb"
BUFILE = BUFOLDER & NOWSTRING & " BACKUP TASC_be.mdb"
message1 = "Your Database has just been backed up. " & vbNewLine &
vbNewLine & "The backup File Name is: " & BUFILE & "." & vbNewLine &
vbNewLine & " It is strongly suggested that you copy that file to a
secure location (such as Dropbox). "
namemsg = "Backup Done"

FileCopy OLDFILE, BUFILE
MsgBox message1, vbOKOnly, namemsg

End Function

This code is called through a macro, which in turn opens a form.

The process works fine under most conditions, but after execution of
some macro/vba-code combinations I get an error code 70 when I try
and execute it, This error does not allow me to copy the file. I have
reduced the number of conditions this happens by going through all
macros to be certain I have closed all hidden forms, but a couple of
conditions continue to elude me.

Does anyone have any suggestions as to how I could either override
this error situation, or find it! For example, is there ANY was one
can see all hidden forms so I can be certain they are closed? Is there
some other condition that could be causing the write to fail?

Help much appreciated.

John Baker
 
D

Douglas J Steele

Don't know whether it contributes to the problem, but you've got the wrong
slashes in your files. It should be

BUFOLDER = "C:\TASC\BACKUP\"

and

OLDFILE = "c:\TASC\DB\TASC_be.mdb"

You definitely should be checking whether or not the database is in use. If
c:\TASC\DB\TASC_be.ldb exists, it's in use and should not be copied (you run
the risk that the copy will be in an inconsistent state)


"JHB" wrote in message

Hi:

I am trying to set up a process where a user can click a button and
backup the active database to another drive with a simple copy.

I have set the following code:

Function BUDB()


Dim OLDFILE As String
Dim BUFILE As String
Dim NOWSTRING As String
BUFOLDER = "C:/TASC/BACKUP/"
NOWSTRING = Format(Now(), "yyyy-mm-dd")
OLDFILE = "c:/TASC/DB/TASC_be.mdb"
BUFILE = BUFOLDER & NOWSTRING & " BACKUP TASC_be.mdb"
message1 = "Your Database has just been backed up. " & vbNewLine &
vbNewLine & "The backup File Name is: " & BUFILE & "." & vbNewLine &
vbNewLine & " It is strongly suggested that you copy that file to a
secure location (such as Dropbox). "
namemsg = "Backup Done"

FileCopy OLDFILE, BUFILE
MsgBox message1, vbOKOnly, namemsg

End Function

This code is called through a macro, which in turn opens a form.

The process works fine under most conditions, but after execution of
some macro/vba-code combinations I get an error code 70 when I try
and execute it, This error does not allow me to copy the file. I have
reduced the number of conditions this happens by going through all
macros to be certain I have closed all hidden forms, but a couple of
conditions continue to elude me.

Does anyone have any suggestions as to how I could either override
this error situation, or find it! For example, is there ANY was one
can see all hidden forms so I can be certain they are closed? Is there
some other condition that could be causing the write to fail?

Help much appreciated.

John Baker
 
J

JHB

Don't know whether it contributes to the problem, but you've got the wrong
slashes in your files. It should be

BUFOLDER = "C:\TASC\BACKUP\"

and

OLDFILE = "c:\TASC\DB\TASC_be.mdb"

You definitely should be checking whether or not the database is in use. If
c:\TASC\DB\TASC_be.ldb exists, it's in use and should not be copied (you run
the risk that the copy will be in an inconsistent state)

"JHB"  wrote in message


Hi:

I am trying to set up a process where a user can click a button and
backup the active database to another drive with a simple copy.

I have set the following code:

Function BUDB()

Dim OLDFILE As String
Dim BUFILE As String
Dim NOWSTRING As String
BUFOLDER = "C:/TASC/BACKUP/"
NOWSTRING = Format(Now(), "yyyy-mm-dd")
OLDFILE = "c:/TASC/DB/TASC_be.mdb"
BUFILE = BUFOLDER & NOWSTRING & " BACKUP TASC_be.mdb"
message1 = "Your Database has just been backed up.  " & vbNewLine &
vbNewLine & "The backup File Name is: " & BUFILE & "." & vbNewLine &
vbNewLine & " It is strongly suggested that you copy that file to a
secure location (such as Dropbox). "
namemsg = "Backup Done"

FileCopy OLDFILE, BUFILE
MsgBox message1, vbOKOnly, namemsg

End Function

This code  is called through a macro, which in turn opens a form.

The process works fine under most conditions, but after execution of
some macro/vba-code combinations  I get an error code 70 when I try
and execute it, This error does not allow me to copy the file. I have
reduced the number of conditions this happens by going through all
macros to be certain I have closed all hidden forms, but a couple of
conditions continue to elude me.

Does anyone have any suggestions as to how I could either override
this error situation, or find it! For example, is there ANY was one
can see all hidden forms so I can be certain they are closed? Is there
some other condition that could be causing the write to fail?

Help much appreciated.

John Baker

Thanks
Indeed it is open..and thats why I cant copy the file. Most of the
time after I have done updating and tidied up it is closed, but for
one function it seems something is stopping it from closing! Do you
know any way to force a close of the ldb file OR find out what is
causing it to remain open?
John
 
D

Douglas J Steele

So I'll assuming your application is split into a front-end and back-end,
and you're trying to copy the back-end from the front-end.

Any open connection between the front-end and back-end will cause there to
be a locking file. That means that the only form(s) that can be open must be
unbound (or at least bound only to tables in the front-end).

"JHB" wrote in message

Don't know whether it contributes to the problem, but you've got the wrong
slashes in your files. It should be

BUFOLDER = "C:\TASC\BACKUP\"

and

OLDFILE = "c:\TASC\DB\TASC_be.mdb"

You definitely should be checking whether or not the database is in use.
If
c:\TASC\DB\TASC_be.ldb exists, it's in use and should not be copied (you
run
the risk that the copy will be in an inconsistent state)

"JHB" wrote in message


Hi:

I am trying to set up a process where a user can click a button and
backup the active database to another drive with a simple copy.

I have set the following code:

Function BUDB()

Dim OLDFILE As String
Dim BUFILE As String
Dim NOWSTRING As String
BUFOLDER = "C:/TASC/BACKUP/"
NOWSTRING = Format(Now(), "yyyy-mm-dd")
OLDFILE = "c:/TASC/DB/TASC_be.mdb"
BUFILE = BUFOLDER & NOWSTRING & " BACKUP TASC_be.mdb"
message1 = "Your Database has just been backed up. " & vbNewLine &
vbNewLine & "The backup File Name is: " & BUFILE & "." & vbNewLine &
vbNewLine & " It is strongly suggested that you copy that file to a
secure location (such as Dropbox). "
namemsg = "Backup Done"

FileCopy OLDFILE, BUFILE
MsgBox message1, vbOKOnly, namemsg

End Function

This code is called through a macro, which in turn opens a form.

The process works fine under most conditions, but after execution of
some macro/vba-code combinations I get an error code 70 when I try
and execute it, This error does not allow me to copy the file. I have
reduced the number of conditions this happens by going through all
macros to be certain I have closed all hidden forms, but a couple of
conditions continue to elude me.

Does anyone have any suggestions as to how I could either override
this error situation, or find it! For example, is there ANY was one
can see all hidden forms so I can be certain they are closed? Is there
some other condition that could be causing the write to fail?

Help much appreciated.

John Baker

Thanks
Indeed it is open..and thats why I cant copy the file. Most of the
time after I have done updating and tidied up it is closed, but for
one function it seems something is stopping it from closing! Do you
know any way to force a close of the ldb file OR find out what is
causing it to remain open?
John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top