Make backup copy when closing

S

Sverk

Hi,
I´m using Access 2002, in Windows XP.
When I close a database it is saved automatically, OK, but I want to get a
few more things done then, especially to make a safety backup copy of the
..mdb file to a different drive or folder.
I am trying to do it by putting a FileCopy statement in the form-exit event
but always get the "Permission denied" message. I suppose that's because the
database is still open, but how could it be done otherwise?
Please help,
Sverk
(new to Access, but quite at home with Visual Basic)
 
S

Sverk

Thanks a lot, just what I needed.
I'll be getting back to that site often.

Three matters though:
1. In the Function fDBExclusive(), the line
Dim db As Database
gives "User-defined type not defined"
I commented out the line where this function is called, don't really need
it, and it all worked just fine; still, how can it be fixed?

2. My database is split, thus it also has a *_be.mdb file which need to
be copied as well. Am I right thinking the actual file copy is made by the
line
lngRet = apiSHFileOperation(tshFileOp)
using the filenames etc specified by the tshFileOp right above it?
I suppose I can just insert this part once more, with the -be.mdb names
instead, right?

3. The Function fCurrentDBDir() is not called (could be useful at other
points though).

Sverk





"Alex Dybenko" skrev:
 
D

Douglas J. Steele

In-line

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Sverk said:
Thanks a lot, just what I needed.
I'll be getting back to that site often.

Three matters though:
1. In the Function fDBExclusive(), the line
Dim db As Database
gives "User-defined type not defined"
I commented out the line where this function is called, don't really need
it, and it all worked just fine; still, how can it be fixed?

Database is a DAO object. By default, Access 2002 uses ADO.

With any code module open, select Tools | References from the menu bar,
scroll through the list of available references until you find the one for
Microsoft DAO 3.6 Object Library, and select it. If you're not going to be
using ADO, uncheck the reference to Microsoft ActiveX Data Objects 2.1
Library

If you have both references, you'll find that you'll need to "disambiguate"
certain declarations, because objects with the same names exist in the 2
models. For example, to ensure that you get a DAO recordset, you'll need to
use Dim rsCurr as DAO.Recordset (to guarantee an ADO recordset, you'd use
Dim rsCurr As ADODB.Recordset)

The list of objects with the same names in the 2 models is Connection,
Error, Errors, Field, Fields, Parameter, Parameters, Property, Properties
and Recordset
2. My database is split, thus it also has a *_be.mdb file which need
to
be copied as well. Am I right thinking the actual file copy is made by
the
line
lngRet = apiSHFileOperation(tshFileOp)
using the filenames etc specified by the tshFileOp right above it?
I suppose I can just insert this part once more, with the -be.mdb names
instead, right?

To copy multiple files, separate the file names with vbNullChar, and put an
extra vbNullChar at the end, as in:

.pFrom = CurrentDb.Name & vbNullChar & _
strBackendDatabase & vbNullChar & vbNullChar

3. The Function fCurrentDBDir() is not called (could be useful at
other
points though).

You're right.
 
S

Sverk

Hi,
I tried to include the back-end file the way I said in my point 2, and it
worked OK, but your way seems smarter, and probably handles flags and errors
better than my way.
I'll see about the DAO vs. ADO later.
Thanks a lot,
Sverk

"Douglas J. Steele" skrev:
 

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