PC Review


Reply
Thread Tools Rate Thread

copy MDB to new name, while in use.

 
 
=?Utf-8?B?UHJvZ3JhbW1lciAtIHdhbm5hQg==?=
Guest
Posts: n/a
 
      26th Oct 2007
I have No idea where to begin, this may be a VB script or an ACCESS VBA
project, I would really appreciate any help I can get on this. I would like
to build a Script that can be run from a command button in ACCESS2003. The
Script needs to check to see if the TESTDB in a subfolder of the primary
database is in use;

If the TESTDB is in use then display a message that the adhoc DB is in use
would you like to create a temp adhocDB,
if YES then copy the current MDB to the subfolder and name it
adhoctemp%currentdate-time%.mdb, remove all the Start restrictions that were
in place by way of options from Tools/Startup on the Master DB and place the
use in the adhocDB. When the user closes this db they should be returned to
the master and the adhoc should be deleted.
If NO then do nothing
If the TESTDB is NOT in use then delete all data from the tables and
repopulate with data from the Master DB, remove all restrictions that were in
place by way of options from Tools/Startup on the Master DB and place the use
in the TESTDB. When the user closes this they should just be returned to the
master.

Just thinking about this scares me. Would someone out there please help me.
Thank you!! :-)
 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      26th Oct 2007
I would advise very strongly against trying to copy the currently open
database. There's no guarantee that it'll end up in a consistent state.

What you could do is use the TransferDatabase method to copy the tables from
the current database to the other one.

To check whether a given database is in use, see whether the locking file
exists in the folder. In other words, if you're trying to determine whether
C:\Folder1\Folder2\TestDB.mdb is in use, look to see whether
C:\Folder1\Folder2\TestDB.ldb exists. You can check whether a file exists
using the Dir function:

If Len(Dir("C:\Folder1\Folder2\TestDB.ldb")) > 0 Then
' The file exists
Else
' The file does not exist
End If

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


"Programmer - wannaB" <(E-Mail Removed)> wrote in
message news:8E2A2A91-B3E2-4477-967B-(E-Mail Removed)...
>I have No idea where to begin, this may be a VB script or an ACCESS VBA
> project, I would really appreciate any help I can get on this. I would
> like
> to build a Script that can be run from a command button in ACCESS2003. The
> Script needs to check to see if the TESTDB in a subfolder of the primary
> database is in use;
>
> If the TESTDB is in use then display a message that the adhoc DB is in use
> would you like to create a temp adhocDB,
> if YES then copy the current MDB to the subfolder and name it
> adhoctemp%currentdate-time%.mdb, remove all the Start restrictions that
> were
> in place by way of options from Tools/Startup on the Master DB and place
> the
> use in the adhocDB. When the user closes this db they should be returned
> to
> the master and the adhoc should be deleted.
> If NO then do nothing
> If the TESTDB is NOT in use then delete all data from the tables and
> repopulate with data from the Master DB, remove all restrictions that were
> in
> place by way of options from Tools/Startup on the Master DB and place the
> use
> in the TESTDB. When the user closes this they should just be returned to
> the
> master.
>
> Just thinking about this scares me. Would someone out there please help
> me.
> Thank you!! :-)



 
Reply With Quote
 
=?Utf-8?B?UHJvZ3JhbW1lciAtIHdhbm5hQg==?=
Guest
Posts: n/a
 
      26th Oct 2007
WOW, Thank you so much for that rapid reply Doug!!! U pref Doug or Gouglas?
I had thought of the ldb file exsistance but I also know that file can be
left behind on occasion when the db has been exited in the wrong way. I was
just revising my question to this>>>

OK as I thought this over a bit more I have simplified it down to this. AND
again I would really appreciate anyone’s help in writing the code for
something like this. I also think it would all be VBA. I had thought VB
script might be needed if I were copying the MDB file, because I can copy and
paste that file all day from DOS or windows explorer, but I could not find
any VBA that would copy an active MDB.
Anyway here is the breakdown of what I am looking to do.
Thank you!!

If TESTDB.ldb then (or is there a better way to know if TESTDB is in use)
place the use in the TESTDB.
ELSE
(If the TESTDB is NOT in use) then delete all data from the tables and
repopulate with data from the Master DB, and then place the use in the TESTDB.
(Should the CompactDatabase be run on TESTDB after a purge and reload of
data?)
=====================================

"Douglas J. Steele" wrote:

> I would advise very strongly against trying to copy the currently open
> database. There's no guarantee that it'll end up in a consistent state.
>
> What you could do is use the TransferDatabase method to copy the tables from
> the current database to the other one.
>
> To check whether a given database is in use, see whether the locking file
> exists in the folder. In other words, if you're trying to determine whether
> C:\Folder1\Folder2\TestDB.mdb is in use, look to see whether
> C:\Folder1\Folder2\TestDB.ldb exists. You can check whether a file exists
> using the Dir function:
>
> If Len(Dir("C:\Folder1\Folder2\TestDB.ldb")) > 0 Then
> ' The file exists
> Else
> ' The file does not exist
> End If
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "Programmer - wannaB" <(E-Mail Removed)> wrote in
> message news:8E2A2A91-B3E2-4477-967B-(E-Mail Removed)...
> >I have No idea where to begin, this may be a VB script or an ACCESS VBA
> > project, I would really appreciate any help I can get on this. I would
> > like
> > to build a Script that can be run from a command button in ACCESS2003. The
> > Script needs to check to see if the TESTDB in a subfolder of the primary
> > database is in use;
> >
> > If the TESTDB is in use then display a message that the adhoc DB is in use
> > would you like to create a temp adhocDB,
> > if YES then copy the current MDB to the subfolder and name it
> > adhoctemp%currentdate-time%.mdb, remove all the Start restrictions that
> > were
> > in place by way of options from Tools/Startup on the Master DB and place
> > the
> > use in the adhocDB. When the user closes this db they should be returned
> > to
> > the master and the adhoc should be deleted.
> > If NO then do nothing
> > If the TESTDB is NOT in use then delete all data from the tables and
> > repopulate with data from the Master DB, remove all restrictions that were
> > in
> > place by way of options from Tools/Startup on the Master DB and place the
> > use
> > in the TESTDB. When the user closes this they should just be returned to
> > the
> > master.
> >
> > Just thinking about this scares me. Would someone out there please help
> > me.
> > Thank you!! :-)

>
>
>

 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      26th Oct 2007
While you're correct that the ldb file can be left behind in certain
conditions, I'm not aware of any other check you can make.

I'm not quite sure what your "place the use in the TESTDB" option is
supposed to do. The ELSE side, though, sounds correct. You definitely want
to run CompactDatabase on the TESTDB. In fact, if the tables are big, you
might want to compact after the purge, and then again after the load.

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


"Programmer - wannaB" <(E-Mail Removed)> wrote in
message news:7ECB23E3-73C4-4439-BD08-(E-Mail Removed)...
> WOW, Thank you so much for that rapid reply Doug!!! U pref Doug or
> Gouglas?
> I had thought of the ldb file exsistance but I also know that file can be
> left behind on occasion when the db has been exited in the wrong way. I
> was
> just revising my question to this>>>
>
> OK as I thought this over a bit more I have simplified it down to this.
> AND
> again I would really appreciate anyone's help in writing the code for
> something like this. I also think it would all be VBA. I had thought VB
> script might be needed if I were copying the MDB file, because I can copy
> and
> paste that file all day from DOS or windows explorer, but I could not find
> any VBA that would copy an active MDB.
> Anyway here is the breakdown of what I am looking to do.
> Thank you!!
>
> If TESTDB.ldb then (or is there a better way to know if TESTDB is in
> use)
> place the use in the TESTDB.
> ELSE
> (If the TESTDB is NOT in use) then delete all data from the tables and
> repopulate with data from the Master DB, and then place the use in the
> TESTDB.
> (Should the CompactDatabase be run on TESTDB after a purge and reload of
> data?)
> =====================================
>
> "Douglas J. Steele" wrote:
>
>> I would advise very strongly against trying to copy the currently open
>> database. There's no guarantee that it'll end up in a consistent state.
>>
>> What you could do is use the TransferDatabase method to copy the tables
>> from
>> the current database to the other one.
>>
>> To check whether a given database is in use, see whether the locking file
>> exists in the folder. In other words, if you're trying to determine
>> whether
>> C:\Folder1\Folder2\TestDB.mdb is in use, look to see whether
>> C:\Folder1\Folder2\TestDB.ldb exists. You can check whether a file exists
>> using the Dir function:
>>
>> If Len(Dir("C:\Folder1\Folder2\TestDB.ldb")) > 0 Then
>> ' The file exists
>> Else
>> ' The file does not exist
>> End If
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no private e-mails, please)
>>
>>
>> "Programmer - wannaB" <(E-Mail Removed)> wrote
>> in
>> message news:8E2A2A91-B3E2-4477-967B-(E-Mail Removed)...
>> >I have No idea where to begin, this may be a VB script or an ACCESS VBA
>> > project, I would really appreciate any help I can get on this. I would
>> > like
>> > to build a Script that can be run from a command button in ACCESS2003.
>> > The
>> > Script needs to check to see if the TESTDB in a subfolder of the
>> > primary
>> > database is in use;
>> >
>> > If the TESTDB is in use then display a message that the adhoc DB is in
>> > use
>> > would you like to create a temp adhocDB,
>> > if YES then copy the current MDB to the subfolder and name it
>> > adhoctemp%currentdate-time%.mdb, remove all the Start restrictions that
>> > were
>> > in place by way of options from Tools/Startup on the Master DB and
>> > place
>> > the
>> > use in the adhocDB. When the user closes this db they should be
>> > returned
>> > to
>> > the master and the adhoc should be deleted.
>> > If NO then do nothing
>> > If the TESTDB is NOT in use then delete all data from the tables and
>> > repopulate with data from the Master DB, remove all restrictions that
>> > were
>> > in
>> > place by way of options from Tools/Startup on the Master DB and place
>> > the
>> > use
>> > in the TESTDB. When the user closes this they should just be returned
>> > to
>> > the
>> > master.
>> >
>> > Just thinking about this scares me. Would someone out there please
>> > help
>> > me.
>> > Thank you!! :-)

>>
>>
>>



 
Reply With Quote
 
David W. Fenton
Guest
Posts: n/a
 
      27th Oct 2007
"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in
news:uC$(E-Mail Removed):

> While you're correct that the ldb file can be left behind in
> certain conditions, I'm not aware of any other check you can make.


Attempting to delete the LDB file would be a pretty good indication
that you shouldn't copy the MDB file. Even if there were no users in
the MDB file, if the LDB file is still locked by the file system
(because it's open) it might be an indication that something is
still marked as locked or suspect in the MDB file.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
 
Reply With Quote
 
WANNABE
Guest
Posts: n/a
 
      29th Oct 2007
That would be a typing error,which should say USER not USE (open the database
and make it the current DB). So with that said can you help me to write the
code needed to accomplish this?
=====================================
"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:uC$(E-Mail Removed)...
While you're correct that the ldb file can be left behind in certain
conditions, I'm not aware of any other check you can make.

I'm not quite sure what your "place the use in the TESTDB" option is
supposed to do. The ELSE side, though, sounds correct. You definitely want
to run CompactDatabase on the TESTDB. In fact, if the tables are big, you
might want to compact after the purge, and then again after the load.

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


"Programmer - wannaB" <(E-Mail Removed)> wrote in
message news:7ECB23E3-73C4-4439-BD08-(E-Mail Removed)...
> WOW, Thank you so much for that rapid reply Doug!!! U pref Doug or
> Gouglas?
> I had thought of the ldb file exsistance but I also know that file can be
> left behind on occasion when the db has been exited in the wrong way. I
> was
> just revising my question to this>>>
>
> OK as I thought this over a bit more I have simplified it down to this.
> AND
> again I would really appreciate anyone's help in writing the code for
> something like this. I also think it would all be VBA. I had thought VB
> script might be needed if I were copying the MDB file, because I can copy
> and
> paste that file all day from DOS or windows explorer, but I could not find
> any VBA that would copy an active MDB.
> Anyway here is the breakdown of what I am looking to do.
> Thank you!!
>
> If TESTDB.ldb then (or is there a better way to know if TESTDB is in
> use)
> place the use in the TESTDB.
> ELSE
> (If the TESTDB is NOT in use) then delete all data from the tables and
> repopulate with data from the Master DB, and then place the use in the
> TESTDB.
> (Should the CompactDatabase be run on TESTDB after a purge and reload of
> data?)
> =====================================
>
> "Douglas J. Steele" wrote:
>
>> I would advise very strongly against trying to copy the currently open
>> database. There's no guarantee that it'll end up in a consistent state.
>>
>> What you could do is use the TransferDatabase method to copy the tables
>> from
>> the current database to the other one.
>>
>> To check whether a given database is in use, see whether the locking file
>> exists in the folder. In other words, if you're trying to determine
>> whether
>> C:\Folder1\Folder2\TestDB.mdb is in use, look to see whether
>> C:\Folder1\Folder2\TestDB.ldb exists. You can check whether a file exists
>> using the Dir function:
>>
>> If Len(Dir("C:\Folder1\Folder2\TestDB.ldb")) > 0 Then
>> ' The file exists
>> Else
>> ' The file does not exist
>> End If
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no private e-mails, please)
>>
>>
>> "Programmer - wannaB" <(E-Mail Removed)> wrote
>> in
>> message news:8E2A2A91-B3E2-4477-967B-(E-Mail Removed)...
>> >I have No idea where to begin, this may be a VB script or an ACCESS VBA
>> > project, I would really appreciate any help I can get on this. I would
>> > like
>> > to build a Script that can be run from a command button in ACCESS2003.
>> > The
>> > Script needs to check to see if the TESTDB in a subfolder of the
>> > primary
>> > database is in use;
>> >
>> > If the TESTDB is in use then display a message that the adhoc DB is in
>> > use
>> > would you like to create a temp adhocDB,
>> > if YES then copy the current MDB to the subfolder and name it
>> > adhoctemp%currentdate-time%.mdb, remove all the Start restrictions that
>> > were
>> > in place by way of options from Tools/Startup on the Master DB and
>> > place
>> > the
>> > use in the adhocDB. When the user closes this db they should be
>> > returned
>> > to
>> > the master and the adhoc should be deleted.
>> > If NO then do nothing
>> > If the TESTDB is NOT in use then delete all data from the tables and
>> > repopulate with data from the Master DB, remove all restrictions that
>> > were
>> > in
>> > place by way of options from Tools/Startup on the Master DB and place
>> > the
>> > use
>> > in the TESTDB. When the user closes this they should just be returned
>> > to
>> > the
>> > master.
>> >
>> > Just thinking about this scares me. Would someone out there please
>> > help
>> > me.
>> > Thank you!! :-)

>>
>>
>>




 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
http://LongPathTool.com - find and delete/copy path too long filesfrom your hard drive or LAN Windows tool to copy or delete files and folderswith path too long or filename too long error. Just browse to the file andpress a button to copy or d Martin Krag Windows XP Internet Explorer 0 22nd Apr 2011 10:08 AM
http://LongPathTool.com - find and delete/copy path too long filesfrom your hard drive or LAN Windows tool to copy or delete files and folderswith path too long or filename too long error. Just browse to the file andpress a button to copy or d Martin Krag Windows XP Configuration 0 22nd Apr 2011 10:05 AM
Copy local users and groups, copy shares with security, copy homeuser folders usenet@sphere10.com Microsoft Windows 2000 Active Directory 1 17th Feb 2009 01:31 PM
Copy local users and groups, copy shares with security, copy homeuser folders usenet@sphere10.com Windows Vista General Discussion 2 17th Feb 2009 01:31 PM
EXCEL FILE a copy/a copy/a copy ....filename =?Utf-8?B?dmU=?= Microsoft Excel New Users 1 29th Sep 2005 09:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:26 AM.