Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / February 2006

Tip: Looking for answers? Try searching our database.

Make backup copy when closing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sverk - 05 Feb 2006 00:30 GMT
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)
Alex Dybenko - 05 Feb 2006 16:10 GMT
Hi,
try to look here:
http://www.mvps.org/access/api/api0026.htm

Signature

Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

> Hi,
> I´m using Access 2002, in Windows XP.
[quoted text clipped - 9 lines]
> Sverk
> (new to Access, but quite at home with Visual Basic)
Sverk - 05 Feb 2006 21:06 GMT
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:

> Hi,
> try to look here:
[quoted text clipped - 13 lines]
> > Sverk
> > (new to Access, but quite at home with Visual Basic)
Douglas J. Steele - 05 Feb 2006 21:18 GMT
In-line

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

> Thanks a lot, just what I needed.
> I'll be getting back to that site often.
[quoted text clipped - 5 lines]
> 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
[quoted text clipped - 5 lines]
> 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.

> Sverk
Sverk - 05 Feb 2006 21:54 GMT
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:

> In-line
>
[quoted text clipped - 49 lines]
>
> > Sverk
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.